From 0e46ec4a08f00c5c43881e1e03c5df3bd09c8af6 Mon Sep 17 00:00:00 2001 From: Mohammad Alavi Date: Fri, 15 Apr 2022 12:07:24 +0430 Subject: [PATCH] feat!: let admin access all routes through policy --- app/Ship/Parents/Policies/Policy.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/Ship/Parents/Policies/Policy.php b/app/Ship/Parents/Policies/Policy.php index d780af114..96fb8dc2b 100644 --- a/app/Ship/Parents/Policies/Policy.php +++ b/app/Ship/Parents/Policies/Policy.php @@ -3,8 +3,24 @@ namespace App\Ship\Parents\Policies; use Apiato\Core\Abstracts\Policies\Policy as AbstractPolicy; +use App\Ship\Parents\Models\UserModel; abstract class Policy extends AbstractPolicy { + /** + * Perform pre-authorization checks. + * + * @param UserModel $user + * @param string $ability + * @return bool|null + */ + public function before(UserModel $user, string $ability): ?bool + { + //grant access for admins + if (method_exists($user, 'hasAdminRole') && $user->hasAdminRole()) { + return true; + } + return null; + } }