@@ -311,7 +311,7 @@ |
||
| 311 | 311 | $this->loadPermissions(); |
| 312 | 312 | |
| 313 | 313 | return $this->permissions |
| 314 | - ->filter(function (Permission $permission) use ($id) { |
|
| 314 | + ->filter(function(Permission $permission) use ($id) { |
|
| 315 | 315 | return $permission->getKey() == $id; |
| 316 | 316 | }) |
| 317 | 317 | ->first(); |
@@ -170,8 +170,9 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function attachPermission(&$permission, bool $reload = true) |
| 172 | 172 | { |
| 173 | - if ($this->hasPermission($permission)) |
|
| 174 | - return; |
|
| 173 | + if ($this->hasPermission($permission)) { |
|
| 174 | + return; |
|
| 175 | + } |
|
| 175 | 176 | |
| 176 | 177 | event(new AttachingPermission($this, $permission)); |
| 177 | 178 | $permission = $this->permissions()->save($permission); |
@@ -192,8 +193,9 @@ discard block |
||
| 192 | 193 | { |
| 193 | 194 | $permission = $this->getPermissionById($id); |
| 194 | 195 | |
| 195 | - if ($permission !== null) |
|
| 196 | - $this->attachPermission($permission, $reload); |
|
| 196 | + if ($permission !== null) { |
|
| 197 | + $this->attachPermission($permission, $reload); |
|
| 198 | + } |
|
| 197 | 199 | |
| 198 | 200 | return $permission; |
| 199 | 201 | } |
@@ -225,8 +227,9 @@ discard block |
||
| 225 | 227 | */ |
| 226 | 228 | public function detachPermission(&$permission, bool $reload = true) |
| 227 | 229 | { |
| 228 | - if ( ! $this->hasPermission($permission)) |
|
| 229 | - return; |
|
| 230 | + if ( ! $this->hasPermission($permission)) { |
|
| 231 | + return; |
|
| 232 | + } |
|
| 230 | 233 | |
| 231 | 234 | $permission = $this->getPermissionFromGroup($permission); |
| 232 | 235 | |
@@ -247,8 +250,9 @@ discard block |
||
| 247 | 250 | */ |
| 248 | 251 | public function detachPermissionById($id, bool $reload = true) |
| 249 | 252 | { |
| 250 | - if ( ! is_null($permission = $this->getPermissionById($id))) |
|
| 251 | - $this->detachPermission($permission, $reload); |
|
| 253 | + if ( ! is_null($permission = $this->getPermissionById($id))) { |
|
| 254 | + $this->detachPermission($permission, $reload); |
|
| 255 | + } |
|
| 252 | 256 | |
| 253 | 257 | return $permission; |
| 254 | 258 | } |
@@ -296,8 +300,9 @@ discard block |
||
| 296 | 300 | */ |
| 297 | 301 | public function hasPermission($id) |
| 298 | 302 | { |
| 299 | - if ($id instanceof Model) |
|
| 300 | - $id = $id->getKey(); |
|
| 303 | + if ($id instanceof Model) { |
|
| 304 | + $id = $id->getKey(); |
|
| 305 | + } |
|
| 301 | 306 | |
| 302 | 307 | return $this->getPermissionFromGroup($id) !== null; |
| 303 | 308 | } |
@@ -316,8 +321,9 @@ discard block |
||
| 316 | 321 | */ |
| 317 | 322 | private function getPermissionFromGroup($id) |
| 318 | 323 | { |
| 319 | - if ($id instanceof Model) |
|
| 320 | - $id = $id->getKey(); |
|
| 324 | + if ($id instanceof Model) { |
|
| 325 | + $id = $id->getKey(); |
|
| 326 | + } |
|
| 321 | 327 | |
| 322 | 328 | $this->loadPermissions(); |
| 323 | 329 | |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | return ! Auth::makeModel('role') |
| 63 | 63 | ->newQuery() |
| 64 | 64 | ->where('key', Auth::slugRoleKey($value)) |
| 65 | - ->unless(is_null($this->ignored), function (Builder $query) { |
|
| 65 | + ->unless(is_null($this->ignored), function(Builder $query) { |
|
| 66 | 66 | return $query->where('id', '!=', $this->ignored); |
| 67 | 67 | }) |
| 68 | 68 | ->exists(); |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | $this->prefix('{'.self::ROLE_WILDCARD.'}')->group(function () { |
| 40 | 40 | // admin::auth.permissions.roles.detach |
| 41 | 41 | $this->delete('detach', [RolesController::class, 'detach']) |
| 42 | - ->name('detach'); |
|
| 42 | + ->name('detach'); |
|
| 43 | 43 | }); |
| 44 | 44 | }); |
| 45 | 45 | } |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function map(): void |
| 37 | 37 | { |
| 38 | - $this->prefix('roles')->name('roles.')->group(function () { |
|
| 39 | - $this->prefix('{'.self::ROLE_WILDCARD.'}')->group(function () { |
|
| 38 | + $this->prefix('roles')->name('roles.')->group(function() { |
|
| 39 | + $this->prefix('{'.self::ROLE_WILDCARD.'}')->group(function() { |
|
| 40 | 40 | // admin::auth.permissions.roles.detach |
| 41 | 41 | $this->delete('detach', [RolesController::class, 'detach']) |
| 42 | 42 | ->name('detach'); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function bindings(PermissionsRepository $repo): void |
| 53 | 53 | { |
| 54 | - $this->bind(self::ROLE_WILDCARD, function (string $uuid, Route $route) use ($repo) { |
|
| 54 | + $this->bind(self::ROLE_WILDCARD, function(string $uuid, Route $route) use ($repo) { |
|
| 55 | 55 | /** @var \Arcanesoft\Foundation\Auth\Models\Permission $permission */ |
| 56 | 56 | $permission = $route->parameter(PermissionsRoutes::PERMISSION_WILDCARD); |
| 57 | 57 | |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | $this->adminGroup(function () { |
| 28 | 28 | // admin::authorization.index |
| 29 | 29 | $this->get('/', [DashboardController::class, 'index']) |
| 30 | - ->name('index'); |
|
| 30 | + ->name('index'); |
|
| 31 | 31 | }); |
| 32 | 32 | } |
| 33 | 33 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function map(): void |
| 26 | 26 | { |
| 27 | - $this->adminGroup(function () { |
|
| 27 | + $this->adminGroup(function() { |
|
| 28 | 28 | // admin::authorization.index |
| 29 | 29 | $this->get('/', [DashboardController::class, 'index']) |
| 30 | 30 | ->name('index'); |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function map(): void |
| 36 | 36 | { |
| 37 | - $this->prefix('permissions')->name('permissions.')->group(function () { |
|
| 38 | - $this->prefix('{'.self::PERMISSION_WILDCARD.'}')->group(function () { |
|
| 37 | + $this->prefix('permissions')->name('permissions.')->group(function() { |
|
| 38 | + $this->prefix('{'.self::PERMISSION_WILDCARD.'}')->group(function() { |
|
| 39 | 39 | // admin::auth.roles.permissions.detach |
| 40 | 40 | $this->delete('detach', [PermissionsController::class, 'detach']) |
| 41 | 41 | ->name('detach'); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function bindings(RolesRepository $repo): void |
| 52 | 52 | { |
| 53 | - $this->bind(self::PERMISSION_WILDCARD, function (string $uuid, Route $route) use ($repo) { |
|
| 53 | + $this->bind(self::PERMISSION_WILDCARD, function(string $uuid, Route $route) use ($repo) { |
|
| 54 | 54 | /** @var \Arcanesoft\Foundation\Auth\Models\Role $role */ |
| 55 | 55 | $role = $route->parameter(RolesRoutes::ROLE_WILDCARD); |
| 56 | 56 | |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | protected function moduleGroup(Closure $callback) |
| 29 | 29 | { |
| 30 | 30 | $this->prefix('authorization') |
| 31 | - ->name('auth.') |
|
| 32 | - ->group($callback); |
|
| 31 | + ->name('auth.') |
|
| 32 | + ->group($callback); |
|
| 33 | 33 | } |
| 34 | 34 | } |
@@ -31,8 +31,9 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | public function handle($request, Closure $next, $guard = null) |
| 33 | 33 | { |
| 34 | - if (Auth::guard($guard)->check()) |
|
| 35 | - Auth::guard($guard)->user()->updateLastActivity(); |
|
| 34 | + if (Auth::guard($guard)->check()) { |
|
| 35 | + Auth::guard($guard)->user()->updateLastActivity(); |
|
| 36 | + } |
|
| 36 | 37 | |
| 37 | 38 | return $next($request); |
| 38 | 39 | } |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | public function up(): void |
| 42 | 42 | { |
| 43 | - $this->createSchema(function (Blueprint $table) { |
|
| 43 | + $this->createSchema(function(Blueprint $table) { |
|
| 44 | 44 | $table->unsignedBigInteger('administrator_id'); |
| 45 | 45 | $table->unsignedInteger('role_id'); |
| 46 | 46 | $table->timestamp('created_at')->nullable(); |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | public function up(): void |
| 42 | 42 | { |
| 43 | - $this->createSchema(function (Blueprint $table) { |
|
| 43 | + $this->createSchema(function(Blueprint $table) { |
|
| 44 | 44 | $table->id(); |
| 45 | 45 | $table->uuid('uuid'); |
| 46 | 46 | $table->string('name'); |