Require this package, with Composer, in the root directory of your project.
$ composer require faustbrian/laravel-inviteableAnd then include the service provider within app/config/app.php.
BrianFaust\Inviteable\InviteableServiceProvider::classTo get started, you'll need to publish the vendor assets and migrate:
php artisan vendor:publish --provider="BrianFaust\Inviteable\InviteableServiceProvider" && php artisan migrate
<?php
namespace App;
use BrianFaust\Inviteable\HasInvitesTrait;
use BrianFaust\Inviteable\Interfaces\HasInvites;
use Illuminate\Database\Eloquent\Model;
class User extends Model implements HasInvites
{
use HasInvitesTrait;
}Invite::getNewCode([
'email' => '[email protected]',
]);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);If you discover a security vulnerability within this package, please send an e-mail to Brian Faust at [email protected]. All security vulnerabilities will be promptly addressed.