role == RoleEnum::DRIVER) { return $delivery->user_id == $user->id && $delivery->warehouse_id == $user->warehouse_id; } return $user->warehouse_id == $delivery->warehouse_id; } public function create(User $user) { return $user->role == RoleEnum::ADMIN || $user->role == RoleEnum::DISPATCHER; } public function update(User $user, Delivery $delivery) { return ($user->role == RoleEnum::ADMIN || $user->role == RoleEnum::DISPATCHER) && $delivery->warehouse_id == $user->warehouse_id; } public function delete(User $user, Delivery $delivery) { return $user->role == RoleEnum::ADMIN && $delivery->warehouse_id == $user->warehouse_id; } }