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