Once you create a Filament User resource - you will get a typical user creation form, which will instantly create a new user. What if you want to send an invitation first and allow the User to join from an email? You can do that, too, but there is some custom work needed.
Let's build an invitation System for our Filament!
Setup
Our project setup includes the following:
- Fresh Laravel project
- Filament installation
- Filament setup
Next, we will work on the default User model and resource.
Creating User Resource
We have to create our User resource to manage our Users. Let's do this:
php artisan make:filament-resource User --generate
Create Invitation Model and Database tables
Let's create our migration:
Migration
Schema::create('invitations', function (Blueprint $table) { $table->id(); $table->string('email'); $table->timestamps();});
Then, we can fill our Model:
app/Models/Invitation.php
class Invitation extends Model{ protected $fillable = [ 'email', ];}
As you can see from the setup, it's a pretty basic Model. All we care about - is the email address being invited.
Modify UserResource Create Button Action - to Invite the User
Next on our list, we need to modify the User Create button. We don't want to create the User right away. We want to invite them via email first. So let's...