Roles with Invitations for Staff Members

Filament 3
Also available in Filament 4/5 version

Some applications require users to register for a specific role. This will determine their functionality and what they see inside. For example, if it's a Job Listing Board, HR and Job seekers should see different things.

FilamentExamples ThumbBase (45)

Get the Source Code:

Only This Example

$9

One-time payment

Full source code for Roles with Invitations for Staff Members
Downloadable ZIP file with the source code
Lifetime access to this example
GitHub Sign in with GitHub to buy

Sign in first, then complete your $9 checkout.

Best value — all 169 examples

FilamentExamples Membership

$99 /year
or
$199 lifetime
Access to code of all 169 examples
Future new examples and updates included
FilaCheck Pro package licence included
MCP server included
View membership plans

30-day money-back guarantee

How it works

We start with a roles list in the PHP enum class, as these will be used in Registration:

app/Enum/Role.php:

enum Role: string
{
case JOB_SEEKERS = 'Job Seekers';
case MENTORS = 'Mentors';
case RECRUITERS = 'Recruiters';
case EMPLOYERS = 'Employers';
case FUSE_ADMIN = 'Fuse Admin';
}

Then we create a custom registration page to add a radio select input. From the roles list, we reject the role Fuse Admin.

This Roles radio select is visible only when cookie is_invited isn't set, as users are invited to a specific Role already.

In the mutateFormDataBeforeRegister() method, we handle the invitation when a user registers with the system. Here, we assign the user the Employers role and set the employer_id, which acts as a staff member for the employer.

app/Filament/Pages/Auth/Register.php:

use App\Models\Role;
use Filament\Forms\Form;
use App\Models\Invitation;
use Filament\Forms\Components\Radio;
use Illuminate\Support\Facades\Session;
use Filament\Forms\Components\Component;
use Filament\Pages\Auth\Register as BaseRegister;
 
class Register extends BaseRegister
{
protected function getForms(): array
{
return [
'form' => $this->form(
$this->makeForm()
->schema([
$this->getNameFormComponent(),
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getPasswordConfirmationFormComponent(),
$this->getRoleFormComponent(),
])
->statePath('data'),
),
];
}
// ...
}
The FULL tutorial is available after the purchase: in the Readme file of the official repository you would get invited to.