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