physiotherapy-clinic/app/Policies/AppointmentPolicy.php

43 lines
1.0 KiB
PHP

<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Appointment;
class AppointmentPolicy
{
public function viewAny(User $user): bool
{
return true;
}
public function view(User $user, Appointment $appointment): bool
{
if (in_array($user->role, ['admin', 'manager', 'receptionist'])) {
return true;
}
// Therapists can see their own appointments
return $appointment->user_id === $user->id;
}
public function create(User $user): bool
{
return in_array($user->role, ['admin', 'manager', 'receptionist']);
}
public function update(User $user, Appointment $appointment): bool
{
if (in_array($user->role, ['admin', 'manager', 'receptionist'])) {
return true;
}
// Therapists can update their own appointments
return $appointment->user_id === $user->id;
}
public function delete(User $user, Appointment $appointment): bool
{
return in_array($user->role, ['admin', 'manager']);
}
}