canDo('com.ryo.test.pistures.view') && $user->isAdmin()) { return true; } return $pistures->user_id == user_id() && $pistures->user_type == user_type(); } /** * Determine if the given user can create a pistures. * * @param UserPolicy $user * @param Pistures $pistures * * @return bool */ public function create(UserPolicy $user) { return $user->canDo('com.ryo.test.pistures.create'); } /** * Determine if the given user can update the given pistures. * * @param UserPolicy $user * @param Pistures $pistures * * @return bool */ public function update(UserPolicy $user, Pistures $pistures) { if ($user->canDo('com.ryo.test.pistures.edit') && $user->isAdmin()) { return true; } return $pistures->user_id == user_id() && $pistures->user_type == user_type(); } /** * Determine if the given user can delete the given pistures. * * @param UserPolicy $user * @param Pistures $pistures * * @return bool */ public function destroy(UserPolicy $user, Pistures $pistures) { return $pistures->user_id == user_id() && $pistures->user_type == user_type(); } /** * Determine if the given user can verify the given pistures. * * @param UserPolicy $user * @param Pistures $pistures * * @return bool */ public function verify(UserPolicy $user, Pistures $pistures) { if ($user->canDo('com.ryo.test.pistures.verify')) { return true; } return false; } /** * Determine if the given user can approve the given pistures. * * @param UserPolicy $user * @param Pistures $pistures * * @return bool */ public function approve(UserPolicy $user, Pistures $pistures) { if ($user->canDo('com.ryo.test.pistures.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; } } }