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