PHPackages                             rubik-llc/laravel-invite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. rubik-llc/laravel-invite

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

rubik-llc/laravel-invite
========================

User invitation system for Laravel application

v0.1.0(3y ago)041[3 PRs](https://github.com/rubik-llc/laravel-invite/pulls)MITPHPPHP ^8.1

Since Jun 2Pushed 2y ago1 watchersCompare

[ Source](https://github.com/rubik-llc/laravel-invite)[ Packagist](https://packagist.org/packages/rubik-llc/laravel-invite)[ Docs](https://github.com/rubik-llc/laravel-invite)[ RSS](/packages/rubik-llc-laravel-invite/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (1)Dependencies (13)Versions (5)Used By (0)

\#Laravel invite

[![Platform](https://camo.githubusercontent.com/69c09f29de04e9813d7b160a87878f515b9ba71c4e2d47212f8eb91e59c65604/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6c61726176656c2d726564)](https://camo.githubusercontent.com/69c09f29de04e9813d7b160a87878f515b9ba71c4e2d47212f8eb91e59c65604/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6c61726176656c2d726564)[![Latest Version on Packagist](https://camo.githubusercontent.com/78e0b56bb4dfaee920e6457ae5e8876c412656e3068d30bcc40e8c82beaaadff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f727562696b2d6c6c632f6c61726176656c2d696e766974652e737667)](https://packagist.org/packages/rubik-llc/laravel-invite)[![Check & fix styling](https://camo.githubusercontent.com/247ab56c0e779d10efca589dd1fc9b01f325a85b0f8706e73317a430b6c19721/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f727562696b2d6c6c632f6c61726176656c2d696e766974652f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636865636b253230616e642532306669782532307374796c696e67)](https://github.com/rubik-llc/laravel-invite/actions/workflows/php-cs-fixer.yml)[![GitHub Workflow Status](https://camo.githubusercontent.com/ba21865667d16b7274e734481e483bf7fdb20ff72061f430094db0f12e5959b5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f727562696b2d6c6c632f6c61726176656c2d696e766974652f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/rubik-llc/laravel-invite/actions/workflows/run-tests.yml)[![GitHub](https://camo.githubusercontent.com/047882a2d7b76943571aba06e6625752353deb2d56f764d8e82d610634db6920/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f727562696b2d6c6c632f6c61726176656c2d696e76697465)](LICENSE.md)

A simple invitation system for Eloquent models in your Laravel application. The package doesn't cover sending emails, views or routing.

```
// Make an invitation
Invitation::to('test@example.com')->make();
```

```
$user = User::find(1);

// Make an invitation directly from an Eloquent Model
$user->invitation()->to('test@example.com')->make();
```

```
$referer = User::find(1);

$invitee = User::find(2);

// Set properties of an invitation
Invitation::to('test@example.com')
            ->referer($referer)
            ->invitee($invitee)
            ->expireIn(3, 'days')
            ->make();
```

```
// Accept an invitation
Invitation::findByToken('1234')->accept();
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require rubik-llc/laravel-invite
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="invite-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="invite-config"
```

This is the contents of the published config file:

```
return [

    /*
    |--------------------------------------------------------------------------
    | Invitation class
    |--------------------------------------------------------------------------
    |
    | The invite class that should be used to store and retrieve the invitations.
    | If you specify a different model class, make sure that model extends the default
    | Invitation model that is shipped with this package.
    |
    */

    'invitation_model' => \Rubik\LaravelInvite\Models\Invitation::class,

    /*
    |--------------------------------------------------------------------------
    | Delete on decline
    |--------------------------------------------------------------------------
    |
    | When this option is enabled, whenever an invitation is declined it will automatically
    | be deleted.
    |
    */

    'delete_on_decline' => false,

    /*
    |--------------------------------------------------------------------------
    | Unit
    |--------------------------------------------------------------------------
    |
    | The unit of the values.
    | This package uses Carbon for date and time related calculations, therefore
    | the value of this option should be only values that Carbon accepts.
    | e.g: seconds, minutes, hours, days, weeks, months, years, etc.
    |
    */

    'unit' => 'hours',

    /*
    |--------------------------------------------------------------------------
    | Expire
    |--------------------------------------------------------------------------
    | The default value of when to expire an invitation after its created. It uses
    | the units that are specified above.
    |
    | If the delete.auto value is set to true, it enables a scheduler that executes
    | a command every hour which deletes all invitations that have surpassed the amount
    | of time given in delete.after
    |
    */
    'expire' => [

        'after' => 48,

        'delete' => [
            'auto' => false,
            'after' => 48,
        ],

    ],

];
```

Usage
-----

[](#usage)

### Registering the Referable Model

[](#registering-the-referable-model)

In order to let a model be able to make invitations, simply add the `CanInvite` trait to the class of that model.

```
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Rubik\LaravelInvite\Traits\CanInvite;

class User extends Model
{
    use CanInvite;

    ...
}
```

### Registering the Invitable Model

[](#registering-the-invitable-model)

In order to let a model be able to receive invitations, add the `RecivesInvitation` trait to the class of that model.

```
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Rubik\LaravelInvite\Traits\RecivesInvitation;

class User extends Model
{
    use RecivesInvitation;

    ...
}
```

### Making invitations

[](#making-invitations)

There are two ways to make an invitation:

#### 1. Making invitations using the Facade

[](#1-making-invitations-using-the-facade)

```
use Rubik\LaravelInvite\Facades\Invitation;

Invitation::to('test@example.com')->make();
```

#### 2. Making invitations from a referer Model

[](#2-making-invitations-from-a-referer-model)

Making an invitation from a model will automatically set in as the referer. Make sure the model class uses the `CanInvite` trait.

```
$user = User::find(1);

$invitation = $user->invitation()->to('test@example.com')->make();

$invitation->referable // will return the user that made the invitation.
```

**NOTE**: An email is required in order to make an invitation.

Additionally, you can specify other parameters like:

### Referer

[](#referer)

You can associate a referer to an invitation using the `referer` method which accepts an eloquent model as a parameter.

```
$referer = User::find(1);

Invitation::to('test@example.com')->referer($referer)->make();
```

or update the referer of an existing invitation.

```
$invitation = Invitation::find(1);

$invitation->referer($anotherReferer);
```

### Invitee

[](#invitee)

You can associate an invitee to an invitation using the `invitee` method. This method accepts an eloquent model or a model class name.

- #### Using Eloquent Model

    [](#using-eloquent-model)

This option should be used when the invitee is created before the invitation is sent.

```
$invitee = User::find(1);

// Using the Facade
$invitation = Invitation::to('test@example.com')->invitee($invitee)->make();

// Using the Referer Model
$invitation = $user->invitation()->to('test@example.com')->invitee($invitee)->make();

$invitation->invitable // will return an instance of the User model
```

or update the invitee of an existing invitation.

```
$invitation = Invitation::find(1);

$invitation->invitee($anotherInvitee);
```

- #### Using class name

    [](#using-class-name)

This option should be used when the invitee is created after the invitation is accepted, and you want to specify its model class.

```
// Using the Facade
$invitation = Invitation::to('test@example.com')->invitee(User::class)->make();

// Using the Referer Model
$invitation = $user->invitation()->to('test@example.com')->invitee($invitee)->make();

$invitation->invitable_type // will return App/Models/User
```

### Expiration

[](#expiration)

In addition to the config file, you can specify the expiration of a specific invitation using the `expireAt`or `expireIn` methods.

- #### Expire at

    [](#expire-at)

This method accepts a date as string or Carbon instance and sets the invitation `expires_at` property to the given date.

```
use Carbon\Carbon;

// Using the Facade
$invitation = Invitation::to('test@example.com')->expireAt('2022-02-02')-make(); //$invitation->expires_at will return '2022-02-02 00:00:00'
$invitation = Invitation::to('test@example.com')->expireAt('2022-02-02 12:50:30')-make(); //$invitation->expires_at will return '2022-02-02 12:50:30'
$invitation = Invitation::to('test@example.com')->expireAt(Carbon::parse('2022-01-01'))-make(); //$invitation->expires_at will return '2022-01-01 00:00:00'

// Using the Referer Model
$invitation = $user->invitation()->to('test@example.com')->expireAt('2022-02-02')-make(); //$invitation->expires_at will return '2022-02-02 00:00:00'
$invitation = $user->invitation()->to('test@example.com')->expireAt('2022-02-02 12:50:30')-make(); //$invitation->expires_at will return '2022-02-02 12:50:30'
$invitation = $user->invitation()->to('test@example.com')->expireAt(Carbon::parse('2022-01-01'))-make(); //$invitation->expires_at will return '2022-01-01 00:00:00'
```

- #### Expire in

    [](#expire-in)

This method accepts two parameters, the value and unit.

```
use Carbon\Carbon;

// Using the Facade
$invitation = Invitation::to('test@example.com')->expireIn(48, 'hours')-make(); //$invitation->expires_at will return now() + 48 hours
$invitation = Invitation::to('test@example.com')->expireIn(10, 'days')-make(); //$invitation->expires_at will return now() + 10 days

// Using the Referer Model
$invitation = $user->invitation()->to('test@example.com')->expireIn(15, 'minutes')-make();  //$invitation->expires_at will return now() + 15 minutes
$invitation = $user->invitation()->to('test@example.com')->expireIn(2, 'months')-make();  //$invitation->expires_at will return now() + 2 months
```

### Getting an invitation by its token

[](#getting-an-invitation-by-its-token)

```
Invitation::findByToken('1234');
```

### Accepting invitations

[](#accepting-invitations)

```
$invitation->accept();
```

### Declining invitations

[](#declining-invitations)

```
$invitation->decline();
```

### Delete on decline

[](#delete-on-decline)

If `delete_on_decline` option in `config/invite.php` is set to **true**, whenever an invitation is declined it will automatically be deleted.

```
$invitation->decline();

$invitation //null
```

### Auto delete expired invitations

[](#auto-delete-expired-invitations)

Enabling `expire.delete.auto` option in `config/invite.php`, will run `Rubik\LaravelInvite\Commands\DeleteExpiredInvitesCommand` every hour that deletes all invitations the expiry date of which has surpassed the value given in `expire.delete.after` option in `config/invite.php`

### Using a custom Invitation class

[](#using-a-custom-invitation-class)

If you are using a custom invitation class make sure it extends the default `Invitation` class that is shipped with this package.

```
namespace App\Models;
use Rubik\LaravelInvite\Models\Invitation;

class CustomInvitation extends Invitation
{
    ...
}
```

In addition to that, you need to set the `invitation_model` value in the config file to the path of your custom class.

```
// config/invite.php

return [
     ...

    'invitation_model' => App\Models\CustomInvitation::class,

     ...
]
```

Events
------

[](#events)

The package dispatches various events

- ### Rubik\\LaravelInvite\\Events\\InvitationCreated

    [](#rubiklaravelinviteeventsinvitationcreated)

    This event dispatches whenever a new Invitation is created.
- ### Rubik\\LaravelInvite\\Events\\InvitationAccepted

    [](#rubiklaravelinviteeventsinvitationaccepted)

    This event dispatches whenever the `accept` method is called and successfully executed.
- ### Rubik\\LaravelInvite\\Events\\InvitationDeclined

    [](#rubiklaravelinviteeventsinvitationdeclined)

    This event dispatches whenever the `decline` method is called and successfully executed.
- ### Rubik\\LaravelInvite\\Events\\InvitationDeleted

    [](#rubiklaravelinviteeventsinvitationdeleted)

    This event dispatches whenever an Invitation is deleted.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Rron Nela](https://github.com/rronik)
- [Yllndrit Beka](https://github.com/yllndritb)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1440d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7c1f9aba4ff97c724276769d2df23b56a640cc2548340763355e65190bbf758?d=identicon)[rubik.llc.dev](/maintainers/rubik.llc.dev)

---

Top Contributors

[![rronik](https://avatars.githubusercontent.com/u/35034872?v=4)](https://github.com/rronik "rronik (11 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

laravelrubik-llclaravel-invite

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/rubik-llc-laravel-invite/health.svg)

```
[![Health](https://phpackages.com/badges/rubik-llc-laravel-invite/health.svg)](https://phpackages.com/packages/rubik-llc-laravel-invite)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.7M41](/packages/jeffgreco13-filament-breezy)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
