First, pull in the package through Composer.
composer require tshafer/laravel-inviteable:1.0.*@dev
And then include the service provider within app/config/app.php
.
'providers' => [
Tshafer\Inviteable\ServiceProvider::class
];
At last you need to publish and run the migration.
php artisan vendor:publish --provider="Tshafer\Inviteable\ServiceProvider" && php artisan migrate
<?php
namespace App;
use Tshafer\Inviteable\Contracts\Inviteable;
use Tshafer\Inviteable\Traits\Inviteable as InviteableTrait;
use Illuminate\Database\Eloquent\Model;
class User extends Model implements Inviteable
{
use InviteableTrait;
}
Invite::getNewCode([
'email' => 'test@test.io',
]);
Invite::getInviteByCode($invite->code);
Invite::getValidInviteByCode($invite->code);
$invite->claim($user);
if ($invite->claimed()) {
dd('This invite has already been claimed.');
}
dump($invite->claimer);
dump($user->invite);