canDo('our_service.our_service.view') && $user->isAdmin()) { return true; } return $our_service->user_id == user_id() && $our_service->user_type == user_type(); } /** * Determine if the given user can create a our_service. * * @param UserPolicy $user * @param OurService $our_service * * @return bool */ public function create(UserPolicy $user) { return $user->canDo('our_service.our_service.create'); } /** * Determine if the given user can update the given our_service. * * @param UserPolicy $user * @param OurService $our_service * * @return bool */ public function update(UserPolicy $user, OurService $our_service) { if ($user->canDo('our_service.our_service.edit') && $user->isAdmin()) { return true; } return $our_service->user_id == user_id() && $our_service->user_type == user_type(); } /** * Determine if the given user can delete the given our_service. * * @param UserPolicy $user * @param OurService $our_service * * @return bool */ public function destroy(UserPolicy $user, OurService $our_service) { return $our_service->user_id == user_id() && $our_service->user_type == user_type(); } /** * Determine if the given user can verify the given our_service. * * @param UserPolicy $user * @param OurService $our_service * * @return bool */ public function verify(UserPolicy $user, OurService $our_service) { if ($user->canDo('our_service.our_service.verify')) { return true; } return false; } /** * Determine if the given user can approve the given our_service. * * @param UserPolicy $user * @param OurService $our_service * * @return bool */ public function approve(UserPolicy $user, OurService $our_service) { if ($user->canDo('our_service.our_service.approve')) { return true; } return false; } /** * Determine if the user can perform a given action ve. * * @param [type] $user [description] * @param [type] $ability [description] * * @return [type] [description] */ public function before($user, $ability) { if ($user->isSuperuser()) { return true; } } }