role == RoleEnum::ADMIN) { return true; } if($user->role == RoleEnum::DISPATCHER) { return $user->warehouse_id == $showedUser->warehouse_id; } return $user->role == $showedUser->role && $user->warehouse_id == $showedUser->warehouse_id; } public function create(User $user) { return $user->role == RoleEnum::ADMIN; } public function update(User $user, User $updatedUser) { return $user->role == RoleEnum::ADMIN && $user->warehouse_id == $updatedUser->warehouse_id; } public function delete(User $user, User $deletedUser) { return $user->role == RoleEnum::ADMIN && $user->warehouse_id == $deletedUser->warehouse_id; } public function viewCar(User $user, User $carUser) { return $carUser->role == RoleEnum::DRIVER; } }