diff --git a/composer.json b/composer.json index c10f4d1..853a76b 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tripteki/laravelphp-acl", - "version": "1.1.5", + "version": "1.1.8", "description": "Trip Teknologi's Laravel.php ACLs", "readme": "README.md", diff --git a/database/migrations/2023_01_20_000000_create_roles_permissions_table.php b/database/migrations/2023_01_20_000000_create_roles_permissions_table.php index 098b8ac..63d3a00 100644 --- a/database/migrations/2023_01_20_000000_create_roles_permissions_table.php +++ b/database/migrations/2023_01_20_000000_create_roles_permissions_table.php @@ -147,7 +147,7 @@ public function up() app("cache")->store(config("permission.cache.store") != "default" ? config("permission.cache.store") : null)->forget(config("permission.cache.key")); - $this->role->rule(ACLServiceProvider::SUPERUSER); + $this->role->rule(ACLServiceProvider::$SUPERADMIN); } /** diff --git a/src/Providers/ACLServiceProvider.php b/src/Providers/ACLServiceProvider.php index a687312..f17c7f9 100644 --- a/src/Providers/ACLServiceProvider.php +++ b/src/Providers/ACLServiceProvider.php @@ -31,7 +31,12 @@ class ACLServiceProvider extends ServiceProvider /** * @var string */ - public const SUPERUSER = "superuser"; + public static $SUPERADMIN = "superadmin"; + + /** + * @var string + */ + public static $SUPERUSER = "superuser"; /** * @var bool @@ -98,12 +103,12 @@ protected function registerSuperuser() { Gate::before(function ($user, $ability) { - return $user->hasRole(ACLServiceProvider::SUPERUSER) ? true : null; + return $user->hasRole(ACLServiceProvider::$SUPERADMIN) ? true : null; }); // Gate::after(function ($user, $ability) { // - // return $user->hasRole(ACLServiceProvider::SUPERUSER); // + // return $user->hasRole(ACLServiceProvider::$SUPERADMIN); // // }); // } diff --git a/src/Repositories/Eloquent/Admin/ACLPermissionRepository.php b/src/Repositories/Eloquent/Admin/ACLPermissionRepository.php index c3aa33e..297d09c 100644 --- a/src/Repositories/Eloquent/Admin/ACLPermissionRepository.php +++ b/src/Repositories/Eloquent/Admin/ACLPermissionRepository.php @@ -28,7 +28,7 @@ public function all($querystring = []) $content = QueryBuilder::for(app(PermissionModel::class)->query()); - if (! Auth::check() || ! Auth::user()->hasRole(ACLServiceProvider::SUPERUSER)) { + if (! Auth::check() || ! Auth::user()->hasRole(ACLServiceProvider::$SUPERADMIN)) { $content = $content->whereNot("name", "like", "%models%"); } diff --git a/stubs/app/Http/Requests/Admin/ACLs/Permissions/PermissionDestroyValidation.php b/stubs/app/Http/Requests/Admin/ACLs/Permissions/PermissionDestroyValidation.php index 444860d..01809c7 100644 --- a/stubs/app/Http/Requests/Admin/ACLs/Permissions/PermissionDestroyValidation.php +++ b/stubs/app/Http/Requests/Admin/ACLs/Permissions/PermissionDestroyValidation.php @@ -32,7 +32,7 @@ public function authorize() */ public function rules() { - $ownable = Auth::check() && Auth::user()->hasRole(ACLServiceProvider::SUPERUSER) ? "|" : "|not_regex:/models/|"; + $ownable = Auth::check() && Auth::user()->hasRole(ACLServiceProvider::$SUPERADMIN) ? "|" : "|not_regex:/models/|"; return [ diff --git a/stubs/app/Http/Requests/Admin/ACLs/Permissions/PermissionShowValidation.php b/stubs/app/Http/Requests/Admin/ACLs/Permissions/PermissionShowValidation.php index 8cb0432..657fa4a 100644 --- a/stubs/app/Http/Requests/Admin/ACLs/Permissions/PermissionShowValidation.php +++ b/stubs/app/Http/Requests/Admin/ACLs/Permissions/PermissionShowValidation.php @@ -32,7 +32,7 @@ public function authorize() */ public function rules() { - $ownable = Auth::check() && Auth::user()->hasRole(ACLServiceProvider::SUPERUSER) ? "|" : "|not_regex:/models/|"; + $ownable = Auth::check() && Auth::user()->hasRole(ACLServiceProvider::$SUPERADMIN) ? "|" : "|not_regex:/models/|"; return [ diff --git a/stubs/app/Http/Requests/Admin/ACLs/Roles/RoleDestroyValidation.php b/stubs/app/Http/Requests/Admin/ACLs/Roles/RoleDestroyValidation.php index f5c4cdf..179b2d5 100644 --- a/stubs/app/Http/Requests/Admin/ACLs/Roles/RoleDestroyValidation.php +++ b/stubs/app/Http/Requests/Admin/ACLs/Roles/RoleDestroyValidation.php @@ -33,7 +33,7 @@ public function rules() { return [ - "role" => "required|string|not_regex:/^".ACLServiceProvider::SUPERUSER."$/|exists:".config("permission.models.role").",name", + "role" => "required|string|not_regex:/^".ACLServiceProvider::$SUPERADMIN."$/|exists:".config("permission.models.role").",name", ]; } };