Courses

Filament Adminpanel for Booking.com API Project

DB Schema & Install Filament

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.

filament admin panel


DB Schema and Models for Resources

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.

db schema

And here's the list of Models we will create Resources for, in groups step-by-step:

  • User
  • Country / City / Geoobject
  • Apartment Type / Bed Type / Room Type
  • Facility / Facility Category
  • Property / Apartment / Room / Bed
  • Booking

So, let's go do this!


Installing Filament

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.

filament admin panel

avatar
Ngozi Stephen Onyemauche

Hi i am using spatie role and permission package is there another filament package for spatie role and permission. Thanks for the course

avatar

Check all avaliable packages in their webpage https://filamentphp.com/plugins

avatar

It Appears I am using v2.x of Filament ...... a bunch of this tutorial is broken if you install the above way. They refactored Notifications: Filament::notify('success','Password changed successfully.') is now Notification::make() ->title('Password changed successfully.') ->success(); Table: Tables\Columns\Text::make('name') is now Tables\Columns\TextColumn::make('name')

avatar

Well yes, we're using the latest version at the moment of writing the article. Should we have used an older version?