Completed
Push — master ( dcb410...e7354d )
by Stephen
07:30
created
src/z1haze/Acl/Models/Level.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
      * LEVEL
17 17
      * A Level has many users
18 18
      *
19
-     * @return mixed
19
+     * @return \Illuminate\Database\Eloquent\Relations\HasMany
20 20
      */
21 21
     public function users()
22 22
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
     {
49 49
         parent::boot();
50 50
 
51
-        static::deleting(function ($level) {
51
+        static::deleting(function($level) {
52 52
             $level->permissions()->where('level_id', $level->id)->update(['level_id' => null]);
53 53
             foreach ($level->users as $user) {
54 54
                 $user->level()->dissociate()->save();
Please login to merge, or discard this patch.
src/z1haze/Acl/Models/Permission.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      * PERMISSION
29 29
      * A permission belongs to many users
30 30
      *
31
-     * @return mixed
31
+     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
32 32
      */
33 33
     public function users()
34 34
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@
 block discarded – undo
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
         });
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -99,11 +99,13 @@
 block discarded – undo
99 99
      */
100 100
     protected function getUser($user)
101 101
     {
102
-        if (is_int($user))
103
-            $user = config('laravel-acl.user')::find($user);
102
+        if (is_int($user)) {
103
+                    $user = config('laravel-acl.user')::find($user);
104
+        }
104 105
 
105
-        if (!$user)
106
-            throw new UserNotFoundException;
106
+        if (!$user) {
107
+                    throw new UserNotFoundException;
108
+        }
107 109
 
108 110
         return $user;
109 111
     }
Please login to merge, or discard this patch.
src/z1haze/Acl/Traits/UserAndLevel.php 3 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
      * associated to a user by direct or
263 263
      * inheritance
264 264
      *
265
-     * @return mixed
265
+     * @return Collection
266 266
      */
267 267
     protected function cacheGetAllPermissions()
268 268
     {
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      * USER & LEVEL
286 286
      * Return a collection of permissions that
287 287
      * are inherited from a higher level
288
-     * @return mixed
288
+     * @return Collection
289 289
      */
290 290
     protected function cacheGetInheritedPermissions()
291 291
     {
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
      * Modify a given set of permissions, given the action to be taken
348 348
      *
349 349
      * @param $permissions
350
-     * @param $action
350
+     * @param string $action
351 351
      * @return mixed
352 352
      */
353 353
     protected function modifyPermissions($permissions, $action)
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      *
381 381
      * @param $permissions
382 382
      * @param $action
383
-     * @param $model
383
+     * @param string $model
384 384
      * @return mixed
385 385
      * @throws PermissionNotFoundException
386 386
      */
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
      * USER & LEVEL
409 409
      * Helper function to handle adding or negating permissions
410 410
      *
411
-     * @param $model
411
+     * @param string $model
412 412
      * @param $permissionObjects
413 413
      */
414 414
     protected function addOrNegate($model, $permissionObjects, $action)
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
      * USER & LEVEL
425 425
      * Helper function to handle removing permissions
426 426
      *
427
-     * @param $model
427
+     * @param string $model
428 428
      * @param $permissionObjects
429 429
      */
430 430
     protected function remove($model, $permissionObjects)
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
      * USER & LEVEL
444 444
      * Help function to handle syncing permissions
445 445
      *
446
-     * @param $model
446
+     * @param string $model
447 447
      * @param $permissionObjects
448 448
      */
449 449
     protected function sync($model, $permissionObjects)
Please login to merge, or discard this patch.
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -105,11 +105,13 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function clearPermissions()
107 107
     {
108
-        if (is_a($this, config('laravel-acl.user'), true))
109
-            $this->permissions()->detach();
108
+        if (is_a($this, config('laravel-acl.user'), true)) {
109
+                    $this->permissions()->detach();
110
+        }
110 111
 
111
-        if (is_a($this, config('laravel-acl.level'), true))
112
-            config('laravel-acl.permission', Permission::class)::whereLevelId($this->id)->update(['level_id' => null]);
112
+        if (is_a($this, config('laravel-acl.level'), true)) {
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -10 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         return \Cache::remember(
134 134
             'laravel-acl.getAllPermissionsFor' . $model . '_' . $this->id,
135 135
             config('laravel-acl.cacheMinutes'),
136
-            function () {
136
+            function() {
137 137
                 return $this->cacheGetAllPermissions();
138 138
             }
139 139
         );
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         return \Cache::remember(
156 156
             'laravel-acl.getInheritedPermissionsFor' . $model . '_' . $this->id,
157 157
             config('laravel-acl.cacheMinutes'),
158
-            function () {
158
+            function() {
159 159
                 return $this->cacheGetInheritedPermissions();
160 160
             }
161 161
         );
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         return \Cache::remember(
178 178
             'laravel-acl.getAvailablePermissionsFor' . $model . '_' . $this->id,
179 179
             config('laravel-acl.cacheMinutes'),
180
-            function () {
180
+            function() {
181 181
                 return $this->cacheGetAvailablePermissions();
182 182
             }
183 183
         );
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         return \Cache::remember(
201 201
             'laravel-acl.hasPermissionTo_' . $model . '_' . $this->id . '_Permission_' . $permission,
202 202
             config('laravel-acl.cacheMinutes'),
203
-            function () use ($permission) {
203
+            function() use ($permission) {
204 204
                 return $this->cacheHasPermissionTo($permission);
205 205
             }
206 206
         );
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 
267 267
         $allPerms = new Collection();
268 268
 
269
-        $levels->each(function ($level, $key) use (&$allPerms) {
269
+        $levels->each(function($level, $key) use (&$allPerms) {
270 270
             $allPerms = $allPerms->merge($level->permissions);
271 271
         });
272 272
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 
288 288
         $inheritedPerms = new Collection();
289 289
 
290
-        $levels->each(function ($level, $key) use (&$inheritedPerms) {
290
+        $levels->each(function($level, $key) use (&$inheritedPerms) {
291 291
             $inheritedPerms = $inheritedPerms->merge($level->permissions->load('level'));
292 292
         });
293 293
 
@@ -384,8 +384,7 @@  discard block
 block discarded – undo
384 384
                 $permissionsObjects[$permission->id] = ['negated' => true];
385 385
             } else {
386 386
                 $model == 'User' ?
387
-                    array_push($permissionsObjects, $permission->id) :
388
-                    array_push($permissionsObjects, $permission);
387
+                    array_push($permissionsObjects, $permission->id) : array_push($permissionsObjects, $permission);
389 388
             }
390 389
         }
391 390
 
@@ -421,7 +420,7 @@  discard block
 block discarded – undo
421 420
             $this->permissions()->detach($permissionObjects);
422 421
 
423 422
         if ($model == 'Level') {
424
-            config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function ($permission) {
423
+            config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function($permission) {
425 424
                 return $permission->id;
426 425
             }, $permissionObjects))->update(['level_id' => null]);
427 426
         }
@@ -442,7 +441,7 @@  discard block
 block discarded – undo
442 441
         if ($model == 'Level') {
443 442
             $this->clearPermissions();
444 443
 
445
-            config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function ($permission) {
444
+            config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function($permission) {
446 445
                 return $permission->id;
447 446
             }, $permissionObjects))
448 447
                 ->update(['level_id' => $this->id]);
Please login to merge, or discard this patch.
src/z1haze/Acl/Traits/UserOnly.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
         return \Cache::remember(
50 50
             'laravel-acl.getNegatedPermissionsForUser_' . $this->id,
51 51
             config('laravel-acl.cacheMinutes'),
52
-            function () {
52
+            function() {
53 53
                 return $this->cacheGetNegatedPermissions();
54 54
             }
55 55
         );
Please login to merge, or discard this patch.
src/z1haze/Acl/Traits/UserAndPermission.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -59,14 +59,17 @@
 block discarded – undo
59 59
      */
60 60
     protected function getLevel($level)
61 61
     {
62
-        if (is_string($level))
63
-            $level = config('laravel-acl.level', Level::class)::whereName($level)->first();
62
+        if (is_string($level)) {
63
+                    $level = config('laravel-acl.level', Level::class)::whereName($level)->first();
64
+        }
64 65
 
65
-        if (is_int($level))
66
-            $level = config('laravel-acl.level', Level::class)::find($level);
66
+        if (is_int($level)) {
67
+                    $level = config('laravel-acl.level', Level::class)::find($level);
68
+        }
67 69
 
68
-        if (!$level)
69
-            throw new LevelNotFoundException();
70
+        if (!$level) {
71
+                    throw new LevelNotFoundException();
72
+        }
70 73
 
71 74
         return $level;
72 75
     }
Please login to merge, or discard this patch.
src/z1haze/Acl/Providers/AclServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@
 block discarded – undo
12 12
      */
13 13
     public function boot()
14 14
     {
15
-        if($this->app->runningInConsole()) {
15
+        if ($this->app->runningInConsole()) {
16 16
             $this->publishFiles();
17
-            $this->loadMigrationsFrom(__DIR__.'/../../../migrations');
17
+            $this->loadMigrationsFrom(__DIR__ . '/../../../migrations');
18 18
         }
19 19
     }
20 20
 
Please login to merge, or discard this patch.