Schedule for Doctors
Filament 4/5This project demonstrates a doctor's schedule management system. It allows administrators to manage doctors across multiple clinics, set their availability rules, and block time periods for various reasons, such as holidays or conferences.
Get the Source Code:
Only This Example
One-time payment
Sign in with GitHub to buy
Sign in first, then complete your $9 checkout.
FilamentExamples Membership
30-day money-back guarantee
How it works
In this project, we make use of the laraveljutsu/zap package to manage doctor schedules across multiple clinics. The system allows administrators to set availability rules and block time periods for doctors.
Core Models and Relationships
The system uses three main models with many-to-many relationships:
app/Models/User.php (Doctor):
use Zap\Models\Concerns\HasSchedules; class User extends Authenticatable{ use HasFactory, Notifiable, HasSchedules; public function clinics(): BelongsToMany { return $this->belongsToMany(Clinic::class); } public function specialties(): BelongsToMany { return $this->belongsToMany(Specialty::class); } public function isDoctor(): bool { return $this->role === 'doctor'; }}
The HasSchedules trait from the Zap package provides the relationship to schedules and schedule periods.
Schedule Management with Zap Package
The main schedule management happens in the custom Filament page ManageDoctorSchedule. This page demonstrates two key features of the Zap package:
- Creating Availability Rules - Regular working hours for doctors
- Creating Blocked Periods - Time when doctors are unavailable
app/Filament/Pages/ManageDoctorSchedule.php:
use Zap\Facades\Zap; public function createAvailabilityRule(array $data): void{ Zap::for($this->selectedDoctor) ->named('Availability Rule') ->availability() ->from($data['effective_from']) ->to($data['effective_to']) // ...
Next, we will build:
- Schedule Displays
- Working Hours