canDo('leasing.lease.view') && $authUser->isAdmin()) { return true; } return $lease->user_id == user_id() && $lease->user_type == user_type(); } /** * Determine if the given user can create a lease. * * @param UserPolicyInterface $authUser * * @return bool */ public function create(UserPolicyInterface $authUser) { return $authUser->canDo('leasing.lease.create'); } /** * Determine if the given user can update the given lease. * * @param UserPolicyInterface $authUser * @param Lease $lease * * @return bool */ public function update(UserPolicyInterface $authUser, Lease $lease) { if ($authUser->canDo('leasing.lease.edit') && $authUser->isAdmin()) { return true; } return $lease->user_id == user_id() && $lease->user_type == user_type(); } /** * Determine if the given user can delete the given lease. * * @param UserPolicyInterface $authUser * * @return bool */ public function destroy(UserPolicyInterface $authUser, Lease $lease) { return $lease->user_id == user_id() && $lease->user_type == user_type(); } /** * Determine if the given user can verify the given lease. * * @param UserPolicyInterface $authUser * * @return bool */ public function verify(UserPolicyInterface $authUser, Lease $lease) { if ($authUser->canDo('leasing.lease.verify')) { return true; } return false; } /** * Determine if the given user can approve the given lease. * * @param UserPolicyInterface $authUser * * @return bool */ public function approve(UserPolicyInterface $authUser, Lease $lease) { if ($authUser->canDo('leasing.lease.approve')) { return true; } return false; } /** * Determine if the user can perform a given action ve. * * @param [type] $authUser [description] * @param [type] $ability [description] * * @return [type] [description] */ public function before($authUser, $ability) { if ($authUser->isSuperuser()) { return true; } } }