@@ -105,11 +105,13 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function clearPermissions() |
107 | 107 | { |
108 | - if (get_class($this) == config('laravel-acl.user')) |
|
109 | - $this->permissions()->detach(); |
|
108 | + if (get_class($this) == config('laravel-acl.user')) { |
|
109 | + $this->permissions()->detach(); |
|
110 | + } |
|
110 | 111 | |
111 | - if (get_class($this) == config('laravel-acl.level')) |
|
112 | - config('laravel-acl.permission', Permission::class)::whereLevelId($this->id)->update(['level_id' => null]); |
|
112 | + if (get_class($this) == config('laravel-acl.level')) { |
|
113 | + config('laravel-acl.permission', Permission::class)::whereLevelId($this->id)->update(['level_id' => null]); |
|
114 | + } |
|
113 | 115 | } |
114 | 116 | |
115 | 117 | |
@@ -413,11 +415,13 @@ discard block |
||
413 | 415 | */ |
414 | 416 | protected function addOrNegate($model, $permissionObjects, $action) |
415 | 417 | { |
416 | - if ($model == 'User') |
|
417 | - $this->permissions()->attach($permissionObjects); |
|
418 | + if ($model == 'User') { |
|
419 | + $this->permissions()->attach($permissionObjects); |
|
420 | + } |
|
418 | 421 | |
419 | - if ($model == 'Level') |
|
420 | - $this->permissions()->saveMany($permissionObjects); |
|
422 | + if ($model == 'Level') { |
|
423 | + $this->permissions()->saveMany($permissionObjects); |
|
424 | + } |
|
421 | 425 | } |
422 | 426 | |
423 | 427 | /** |
@@ -429,8 +433,9 @@ discard block |
||
429 | 433 | */ |
430 | 434 | protected function remove($model, $permissionObjects) |
431 | 435 | { |
432 | - if ($model == 'User') |
|
433 | - $this->permissions()->detach($permissionObjects); |
|
436 | + if ($model == 'User') { |
|
437 | + $this->permissions()->detach($permissionObjects); |
|
438 | + } |
|
434 | 439 | |
435 | 440 | if ($model == 'Level') { |
436 | 441 | config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function ($permission) { |
@@ -448,8 +453,9 @@ discard block |
||
448 | 453 | */ |
449 | 454 | protected function sync($model, $permissionObjects) |
450 | 455 | { |
451 | - if ($model == 'User') |
|
452 | - $this->permissions()->sync($permissionObjects); |
|
456 | + if ($model == 'User') { |
|
457 | + $this->permissions()->sync($permissionObjects); |
|
458 | + } |
|
453 | 459 | |
454 | 460 | if ($model == 'Level') { |
455 | 461 | $this->clearPermissions(); |
@@ -472,14 +478,17 @@ discard block |
||
472 | 478 | */ |
473 | 479 | protected function getPermission($permission) |
474 | 480 | { |
475 | - if (is_string($permission)) |
|
476 | - $permission = config('laravel-acl.permission', Permission::class)::whereName($permission)->first(); |
|
481 | + if (is_string($permission)) { |
|
482 | + $permission = config('laravel-acl.permission', Permission::class)::whereName($permission)->first(); |
|
483 | + } |
|
477 | 484 | |
478 | - if (is_int($permission)) |
|
479 | - $permission = config('laravel-acl.permission', Permission::class)::find($permission); |
|
485 | + if (is_int($permission)) { |
|
486 | + $permission = config('laravel-acl.permission', Permission::class)::find($permission); |
|
487 | + } |
|
480 | 488 | |
481 | - if (!$permission) |
|
482 | - throw new PermissionNotFoundException; |
|
489 | + if (!$permission) { |
|
490 | + throw new PermissionNotFoundException; |
|
491 | + } |
|
483 | 492 | |
484 | 493 | return $permission; |
485 | 494 | } |
@@ -94,14 +94,17 @@ |
||
94 | 94 | */ |
95 | 95 | protected function getALevel($level) |
96 | 96 | { |
97 | - if (is_string($level)) |
|
98 | - $level = config('laravel-acl.level', Level::class)::whereName($level)->first(); |
|
97 | + if (is_string($level)) { |
|
98 | + $level = config('laravel-acl.level', Level::class)::whereName($level)->first(); |
|
99 | + } |
|
99 | 100 | |
100 | - if (is_int($level)) |
|
101 | - $level = config('laravel-acl.level', Level::class)::find($level); |
|
101 | + if (is_int($level)) { |
|
102 | + $level = config('laravel-acl.level', Level::class)::find($level); |
|
103 | + } |
|
102 | 104 | |
103 | - if (!$level) |
|
104 | - throw new LevelNotFoundException(); |
|
105 | + if (!$level) { |
|
106 | + throw new LevelNotFoundException(); |
|
107 | + } |
|
105 | 108 | |
106 | 109 | return $level; |
107 | 110 | } |