In the first lesson of this course, we will install Filament and will allow only users with the role of administrator to access the admin panel.
So, our plan in this course is to take the existing database with its models, and create adminpanel for them, as Filament Resources, one by one.
So you would have the full pictire, this is the full DB schema of the project.
And here's the list of Models we will create Resources for, in groups step-by-step:
So, let's go do this!
For this first short lesson, we will just install Filament. It's extremely easy.
composer require filament/filament
Next, we need to implement FilamentUser
in the User
model and add the canAccessFilament
method.
app/Models/User.php:
use Filament\Models\Contracts\FilamentUser; class User extends Authenticatable implements FilamentUser{ // ... public function canAccessFilament(): bool { return $this->role_id === Role::ROLE_ADMINISTRATOR; }}
And that's it! We have prepared Filament. You can now log in with the administrator user, by visiting the /admin
URL.
From the initial Booking.com API course, we have such users with users.role_id=1
After logging in, the administrator would see this empty dashboard, with no features, for now.