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