@@ -134,7 +134,7 @@ |
||
| 134 | 134 | { |
| 135 | 135 | parent::boot(); |
| 136 | 136 | |
| 137 | - static::deleting(function ($permission) { |
|
| 137 | + static::deleting(function($permission) { |
|
| 138 | 138 | $permission->users()->detach(); |
| 139 | 139 | $permission->level()->dissociate()->save(); |
| 140 | 140 | }); |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace z1haze\Acl\Traits; |
| 4 | 4 | |
| 5 | -use z1haze\Acl\Exceptions\LevelNotFoundException; |
|
| 6 | 5 | use Illuminate\Support\Facades\Cache; |
| 6 | +use z1haze\Acl\Exceptions\LevelNotFoundException; |
|
| 7 | 7 | use z1haze\Acl\Models\Level; |
| 8 | 8 | |
| 9 | 9 | trait UserAndPermission |
@@ -3,9 +3,9 @@ |
||
| 3 | 3 | namespace z1haze\Acl\Traits; |
| 4 | 4 | |
| 5 | 5 | use Illuminate\Support\Collection; |
| 6 | +use Illuminate\Support\Facades\Cache; |
|
| 6 | 7 | use ReflectionClass; |
| 7 | 8 | use z1haze\Acl\Exceptions\PermissionNotFoundException; |
| 8 | -use Illuminate\Support\Facades\Cache; |
|
| 9 | 9 | use z1haze\Acl\Models\Level; |
| 10 | 10 | use z1haze\Acl\Models\Permission; |
| 11 | 11 | |
@@ -384,7 +384,7 @@ |
||
| 384 | 384 | * for modifyPermissions |
| 385 | 385 | * |
| 386 | 386 | * @param $permissions |
| 387 | - * @param $action |
|
| 387 | + * @param string $action |
|
| 388 | 388 | * @return array |
| 389 | 389 | * @throws PermissionNotFoundException |
| 390 | 390 | */ |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | return Cache::remember( |
| 125 | 125 | 'laravel-acl.getPermissionsFor' . (new ReflectionClass($this))->getShortName() . '_' . $this->id, |
| 126 | 126 | config('laravel-acl.cacheMinutes'), |
| 127 | - function () { |
|
| 127 | + function() { |
|
| 128 | 128 | return $this->cachegetPermissions(); |
| 129 | 129 | } |
| 130 | 130 | ); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | return Cache::remember( |
| 145 | 145 | 'laravel-acl.getAllPermissionsFor' . (new ReflectionClass($this))->getShortName() . '_' . $this->id, |
| 146 | 146 | config('laravel-acl.cacheMinutes'), |
| 147 | - function () { |
|
| 147 | + function() { |
|
| 148 | 148 | return $this->cacheGetAllPermissions(); |
| 149 | 149 | } |
| 150 | 150 | ); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | return Cache::remember( |
| 165 | 165 | 'laravel-acl.getInheritedPermissionsFor' . (new ReflectionClass($this))->getShortName() . '_' . $this->id, |
| 166 | 166 | config('laravel-acl.cacheMinutes'), |
| 167 | - function () { |
|
| 167 | + function() { |
|
| 168 | 168 | return $this->cacheGetInheritedPermissions(); |
| 169 | 169 | } |
| 170 | 170 | ); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | return Cache::remember( |
| 185 | 185 | 'laravel-acl.getAvailablePermissionsFor' . (new ReflectionClass($this))->getShortName() . '_' . $this->id, |
| 186 | 186 | config('laravel-acl.cacheMinutes'), |
| 187 | - function () { |
|
| 187 | + function() { |
|
| 188 | 188 | return $this->cacheGetAvailablePermissions(); |
| 189 | 189 | } |
| 190 | 190 | ); |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | return Cache::remember( |
| 206 | 206 | 'laravel-acl.hasPermissionTo_' . (new ReflectionClass($this))->getShortName() . '_' . $this->id . '_Permission_' . $permission, |
| 207 | 207 | config('laravel-acl.cacheMinutes'), |
| 208 | - function () use ($permission) { |
|
| 208 | + function() use ($permission) { |
|
| 209 | 209 | return $this->cacheHasPermissionTo($permission); |
| 210 | 210 | } |
| 211 | 211 | ); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $allPerms = new Collection(); |
| 285 | 285 | |
| 286 | - $levels->each(function ($level, $key) use (&$allPerms) { |
|
| 286 | + $levels->each(function($level, $key) use (&$allPerms) { |
|
| 287 | 287 | $allPerms = $allPerms->merge($level->permissions); |
| 288 | 288 | }); |
| 289 | 289 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | $inheritedPerms = new Collection(); |
| 308 | 308 | |
| 309 | - $levels->each(function ($level, $key) use (&$inheritedPerms) { |
|
| 309 | + $levels->each(function($level, $key) use (&$inheritedPerms) { |
|
| 310 | 310 | $inheritedPerms = $inheritedPerms->merge($level->permissions->load('level')); |
| 311 | 311 | }); |
| 312 | 312 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | |
| 366 | 366 | $permissionObjects = $this->buildPermissionsArray($permissions, $action); |
| 367 | 367 | |
| 368 | - switch($action) { |
|
| 368 | + switch ($action) { |
|
| 369 | 369 | case 'add': |
| 370 | 370 | case 'negate': |
| 371 | 371 | $this->addOrNegate($permissionObjects, $action); |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | if (is_a($this, config('laravel-acl.level'))) { |
| 441 | - config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function ($permission) { |
|
| 441 | + config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function($permission) { |
|
| 442 | 442 | return $permission->id; |
| 443 | 443 | }, $permissionObjects))->update(['level_id' => null]); |
| 444 | 444 | } |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | if (is_a($this, config('laravel-acl.level'))) { |
| 460 | 460 | $this->clearPermissions(); |
| 461 | 461 | |
| 462 | - config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function ($permission) { |
|
| 462 | + config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function($permission) { |
|
| 463 | 463 | return $permission->id; |
| 464 | 464 | }, $permissionObjects)) |
| 465 | 465 | ->update(['level_id' => $this->id]); |