hasAnyRole(['Admin', 'RH', 'DSI', 'Batiment', 'ParcAuto']); } /** * Determine whether the user can view the model. */ public function view(User $user, IntegrationRequest $integrationRequest): bool { if ($user->hasRole('Admin') || $user->hasRole('RH')) { return true; } // Check if user belongs to a service that has a task in this request return $integrationRequest->serviceTasks() ->whereIn('service_id', $user->roles()->where('name', '!=', 'Prescripteur')->pluck('id')) ->exists(); } /** * Determine whether the user can create models. */ public function create(User $user): bool { return $user->hasAnyRole(['Admin', 'RH', 'Prescripteur', 'DSI', 'Batiment', 'ParcAuto']); } /** * Determine whether the user can update the model. */ public function update(User $user, IntegrationRequest $integrationRequest): bool { return $user->hasAnyRole(['Admin', 'RH']); } /** * Determine whether the user can delete the model. */ public function delete(User $user, IntegrationRequest $integrationRequest): bool { return $user->hasRole('Admin'); } }