Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

DB Schema & Install Filament

Lesson 01/09 2 min read
Autoplay

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

Comments & Discussion

NS
Ngozi Stephen Onyemauche ✓ Link copied!

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

N
Nerijus ✓ Link copied!

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

EH
Eric Haskins ✓ Link copied!

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')

PK
Povilas Korop ✓ Link copied!

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

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.