This package is designed to enable web applications the feature of sending tokenized email invitations to potential new users. The invitation is a record on a invitations table, and once claimed is removed and a new user is added to the users table. This package was designed to work the the Admin Package and the Regulator Package
- Add the package to yuor composer.json file
"jameron/invitations" : "*"
NOTE: Laravel 5.5 users can skip steps 2 and 3
- Add to your providers:
Jameron\Invitations\InvitationsServiceProvider::class,
- Add to your Facades:
'Invitations' => Jameron\Invitations\Facades\InvitationsFacade::class,
-
Publish the migrations and config
php artisan vendor:publish
-
Run migrations
pph artisan migrate
-
If you want to tie related model data to your invitations you can set that in your config/invitations.php config file.
Make sure to add the Invitable Trait to the model you are relating to your invitations:
use Jameron/Invitations/Models/Traits/Invitable;
then in the class add that Trait
use Invitable;
If for example say you are inviting an user to manage a page you created for them. You have a table called pages, with foreign_key user_id currently set to null. You want the page user_id (nullable) set to the invited user once they claim their invite.
Your config would look like this:
'related' => [
'active' => false,
'model' => \App\Page::class,
'resource_route' => 'pages',
'title' => 'Pages',
'id_column' => 'id',
'value_column' => 'title',
'user_foreign_key' => 'user_id',
'owner_foreign_key' => null
],
When the invitation is claimed the page associated to the invitation will be updated with the users id.
- Add to your database/seeds/DatabaseSeeder.php
$this->call(\Jameron\Import\database\seeds\InvitationsSeeder::class);