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