%PDF- %PDF-
Direktori : /home/forge/api-takeaseat.eco-n-tech.co.uk/app/Policies/ |
Current File : //home/forge/api-takeaseat.eco-n-tech.co.uk/app/Policies/BookingPolicy.php |
<?php namespace App\Policies; use App\Models\Booking; use App\Models\User; use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Auth\Access\Response; class BookingPolicy { use HandlesAuthorization; /** * Determine whether the user can view any models. * * @param \App\Models\User $user * @return mixed */ public function viewAny($user) { return true; } /** * Determine whether the user can view the model. * * @param \App\Models\User $user * @param \App\Models\Booking $booking * @return mixed */ public function view($user, Booking $booking) { return $user->id == $booking->user_id || $user->therapist ?? $user->therapist->id == $booking->therapist_id ? Response::allow() : Response::deny('You do not own this booking.'); } /** * Determine whether the user can create models. * * @param \App\Models\User $user * @return mixed */ public function create($user) { return true; } /** * Determine whether the user can update the model. * * @param \App\Models\User $user * @param \App\Models\Booking $booking * @return mixed */ public function update($user, Booking $booking) { return $user->id == $booking->user_id || $user->therapist ?? $user->therapist->id == $booking->therapist_id ? Response::allow() : Response::deny('You do not own this booking.'); } /** * Determine whether the user can delete the model. * * @param \App\Models\User $user * @param \App\Models\Booking $booking * @return mixed */ public function delete($user, Booking $booking) { return $user->id == $booking->user_id || $user->therapist ?? $user->therapist->id == $booking->therapist_id ? Response::allow() : Response::deny('You do not own this booking.'); } /** * Determine whether the user can restore the model. * * @param \App\Models\User $user * @param \App\Models\Booking $booking * @return mixed */ public function restore($user, Booking $booking) { return $user->id == $booking->user_id || $user->therapist ?? $user->therapist->id == $booking->therapist_id ? Response::allow() : Response::deny('You do not own this booking.'); } /** * Determine whether the user can permanently delete the model. * * @param \App\Models\User $user * @param \App\Models\Booking $booking * @return mixed */ public function forceDelete($user, Booking $booking) { return $user->id == $booking->user_id || $user->therapist ?? $user->therapist->id == $booking->therapist_id ? Response::allow() : Response::deny('You do not own this booking.'); } }