From 90fbe1e235ba76f04d07e639e6bf25029db53499 Mon Sep 17 00:00:00 2001 From: boyfromhell Date: Sat, 22 Dec 2018 12:18:52 +0100 Subject: [PATCH 1/6] Update PermissionPolicy.php --- src/Policies/PermissionPolicy.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Policies/PermissionPolicy.php b/src/Policies/PermissionPolicy.php index 594ed0f..2dd72c3 100644 --- a/src/Policies/PermissionPolicy.php +++ b/src/Policies/PermissionPolicy.php @@ -10,6 +10,26 @@ class PermissionPolicy { use HandlesAuthorization; + public function attachAnyRole() + { + return true; + } + + public function detachRole() + { + return true; + } + + public function attachAnyUser() + { + return true; + } + + public function detachUser() + { + return true; + } + public function viewAny(): bool { return true; From 94814425d2b49b39b76fb19eb14afd3d1c6fd57f Mon Sep 17 00:00:00 2001 From: boyfromhell Date: Sat, 22 Dec 2018 12:15:45 +0100 Subject: [PATCH 2/6] Update RolePolicy.php --- src/Policies/RolePolicy.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Policies/RolePolicy.php b/src/Policies/RolePolicy.php index 9840185..c2abe89 100644 --- a/src/Policies/RolePolicy.php +++ b/src/Policies/RolePolicy.php @@ -10,6 +10,26 @@ class RolePolicy { use HandlesAuthorization; + public function attachAnyPermission() + { + return true; + } + + public function detachPermission() + { + return true; + } + + public function attachAnyUser() + { + return true; + } + + public function detachUser() + { + return true; + } + public function viewAny(): bool { return true; From 6e0e48340d386fcfa7e31a609df7b3c55e38f737 Mon Sep 17 00:00:00 2001 From: boyfromhell Date: Sat, 22 Dec 2018 12:25:18 +0100 Subject: [PATCH 3/6] Update Role.php --- src/Resources/Role.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Resources/Role.php b/src/Resources/Role.php index 354f86c..a4a6d50 100644 --- a/src/Resources/Role.php +++ b/src/Resources/Role.php @@ -75,12 +75,15 @@ public function fields(Request $request) } $resourceName = strtolower(substr(strrchr($resource, "\\"), 1)); $resourcePermissions = [ - "create $resourceName" => "create $resourceName", - "update $resourceName" => "update $resourceName", - "view $resourceName" => "view $resourceName", - "delete $resourceName" => "delete $resourceName", - "force delete $resourceName" => "force delete $resourceName", - "restore $resourceName" => "restore $resourceName" + "viewAny $resourceName" => "viewAny $resourceName", + "create $resourceName" => "create $resourceName", + "update $resourceName" => "update $resourceName", + "view $resourceName" => "view $resourceName", + "delete $resourceName" => "delete $resourceName", + "force delete $resourceName" => "force delete $resourceName", + "restore $resourceName" => "restore $resourceName", + "attach $resourceName" => "attach $resourceName", + "detach $resourceName" => "detach $resourceName" ]; foreach ($resourcePermissions as $resourcePermission) { $dbPermision = \DigitalCloud\PermissionTool\Models\Permission::firstOrCreate( From b53b1907d5ea5a4e05d2c0de3f65aeab0596d216 Mon Sep 17 00:00:00 2001 From: boyfromhell Date: Sat, 22 Dec 2018 12:42:00 +0100 Subject: [PATCH 4/6] Update ToolServiceProvider.php --- src/ToolServiceProvider.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ToolServiceProvider.php b/src/ToolServiceProvider.php index 21ab524..160e7d5 100644 --- a/src/ToolServiceProvider.php +++ b/src/ToolServiceProvider.php @@ -32,7 +32,14 @@ public function boot() Gate::policy(config('permission.models.permission'), PermissionPolicy::class); Gate::policy(config('permission.models.role'), RolePolicy::class); - + + //Super admin all permissions + Gate::before(function ($user, $ability) { + if ($user->email == 'mail@example.com') { + return true; + } + }); + Nova::serving(function (ServingNova $event) { // }); From a220a7fe1e281739a4d660b4432c2e52aea064c7 Mon Sep 17 00:00:00 2001 From: Motaz Marouf <41853913+devmtm@users.noreply.github.com> Date: Tue, 22 Jan 2019 10:06:11 +0200 Subject: [PATCH 5/6] Update ToolServiceProvider.php --- src/ToolServiceProvider.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ToolServiceProvider.php b/src/ToolServiceProvider.php index 160e7d5..d901af1 100644 --- a/src/ToolServiceProvider.php +++ b/src/ToolServiceProvider.php @@ -33,12 +33,12 @@ public function boot() Gate::policy(config('permission.models.permission'), PermissionPolicy::class); Gate::policy(config('permission.models.role'), RolePolicy::class); - //Super admin all permissions - Gate::before(function ($user, $ability) { - if ($user->email == 'mail@example.com') { - return true; - } - }); +// Super admin all permissions +// Gate::before(function ($user, $ability) { +// if ($user->email == 'mail@example.com') { +// return true; +// } +// }); Nova::serving(function (ServingNova $event) { // From dad0a7b03a8d85516f45c6c2b470c7bf01b6aee9 Mon Sep 17 00:00:00 2001 From: Motaz Marouf <41853913+devmtm@users.noreply.github.com> Date: Thu, 31 Jan 2019 12:26:11 +0200 Subject: [PATCH 6/6] Fix namespace --- src/Fields/Role.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Role.php b/src/Fields/Role.php index 7972255..a6c207c 100644 --- a/src/Fields/Role.php +++ b/src/Fields/Role.php @@ -36,7 +36,7 @@ public function __construct($name, $attribute = null, $resolveCallback = null) public function options() { return $this->withMeta([ - 'options' => \DC\PermissionTool\Models\Role::get()->map(function ($role) { + 'options' => \DigitalCloud\PermissionTool\Models\Role::get()->map(function ($role) { return [ 'display' => $role->name, 'value' => $role->id,