Hotel Bookings and Hotel Management

Filament 4

This project demonstrates multiple panels in one Filament application: one for hotel management, and another for search and book hotel rooms.

FilamentExamples ThumbBase (2)

Get the Source Code:

How it works

In this Filament Example project, we have two panels:

  • Hotel, for managing hotel with rooms.
  • Booking, for making a room booking.

When a user registers to any panel, they are automatically assigned a role based on the panel. It is done in Eloquent Events closures method in the User Model.

protected static function booted(): void
{
static::created(function (User $user) {
if (filament()->getCurrentOrDefaultPanel()->getId() === 'hotel') {
$user->assignRole('hotels');
}
if (filament()->getCurrentOrDefaultPanel()->getId() === 'booking') {
$user->assignRole('customers');
}
});
}

According to the role, the user gets access to a panel.

public function canAccessPanel(Panel $panel): bool
{
if ($panel->getId() === 'hotel' && $this->hasRole('hotels')) {
return true;
}
 
if ($panel->getId() === 'booking' && $this->hasRole('customers')) {
return true;
}
 
return false;
}

Hotel Panel

In the hotel panel, we have a custom page, MyHotel, where users can manage information about their hotel. It is a HasOne relation to the Hotel Model.

public function hotel(): HasOne
{
return $this->hasOne(Hotel::class);
}

Next, in this example, we will:

  • Build out the Hotel Management
  • Build the Room Management
  • Build a Global Panel to overview Bookings and Rooms
  • Building a page to Book a Room
The FULL tutorial is available after the purchase: in the Readme file of the official repository you would get invited to.
Get the Source Code: All 93 Premium Examples for $99