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