Completed
Push — master ( c436ad...d0a6e2 )
by Stephen
02:15
created
src/z1haze/Acl/Traits/UserAndPermission.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
         return Cache::remember(
61 61
             'laravel-acl.getLevelFor' . $model . '_' . $this->id,
62 62
             config('laravel-acl.cacheMinutes'),
63
-            function () {
63
+            function() {
64 64
                 return $this->cacheGetLevel();
65 65
             }
66 66
         );
Please login to merge, or discard this patch.
src/z1haze/Acl/Traits/UserAndLevel.php 1 patch
Spacing   +16 added lines, -24 removed lines patch added patch discarded remove patch
@@ -36,8 +36,7 @@  discard block
 block discarded – undo
36 36
         $level = $this->getLevel($level);
37 37
 
38 38
         return get_class($this) == config('laravel-acl.level') ?
39
-            $this->rank <= $level->rank :
40
-            $this->level->rank <= $level->rank;
39
+            $this->rank <= $level->rank : $this->level->rank <= $level->rank;
41 40
     }
42 41
 
43 42
     /**
@@ -131,7 +130,7 @@  discard block
 block discarded – undo
131 130
         return \Cache::remember(
132 131
             'laravel-acl.getAllPermissionsFor' . $model . '_' . $this->id,
133 132
             config('laravel-acl.cacheMinutes'),
134
-            function () {
133
+            function() {
135 134
                 return $this->cacheGetAllPermissions();
136 135
             }
137 136
         );
@@ -153,7 +152,7 @@  discard block
 block discarded – undo
153 152
         return \Cache::remember(
154 153
             'laravel-acl.getInheritedPermissionsFor' . $model . '_' . $this->id,
155 154
             config('laravel-acl.cacheMinutes'),
156
-            function () {
155
+            function() {
157 156
                 return $this->cacheGetInheritedPermissions();
158 157
             }
159 158
         );
@@ -175,7 +174,7 @@  discard block
 block discarded – undo
175 174
         return \Cache::remember(
176 175
             'laravel-acl.getAvailablePermissionsFor' . $model . '_' . $this->id,
177 176
             config('laravel-acl.cacheMinutes'),
178
-            function () {
177
+            function() {
179 178
                 return $this->cacheGetAvailablePermissions();
180 179
             }
181 180
         );
@@ -198,7 +197,7 @@  discard block
 block discarded – undo
198 197
         return \Cache::remember(
199 198
             'laravel-acl.hasPermissionTo_' . $model . '_' . $this->id . '_Permission_' . $permission,
200 199
             config('laravel-acl.cacheMinutes'),
201
-            function () use ($permission) {
200
+            function() use ($permission) {
202 201
                 return $this->cacheHasPermissionTo($permission);
203 202
             }
204 203
         );
@@ -215,8 +214,7 @@  discard block
 block discarded – undo
215 214
     public function isLowerThan($other)
216 215
     {
217 216
         return get_class($this) == config('laravel-acl.user') ?
218
-            $this->level->rank > $other->level->rank :
219
-            $this->rank > $other->rank;
217
+            $this->level->rank > $other->level->rank : $this->rank > $other->rank;
220 218
     }
221 219
 
222 220
     /**
@@ -230,8 +228,7 @@  discard block
 block discarded – undo
230 228
     public function isHigherThan($other)
231 229
     {
232 230
         return get_class($this) == config('laravel-acl.user') ?
233
-            $this->level->rank < $other->level->rank :
234
-            $this->rank < $other->rank;
231
+            $this->level->rank < $other->level->rank : $this->rank < $other->rank;
235 232
     }
236 233
 
237 234
     /**
@@ -245,8 +242,7 @@  discard block
 block discarded – undo
245 242
     public function isEqualTo($other)
246 243
     {
247 244
         return get_class($this) == config('laravel-acl.user') ?
248
-            $this->level->rank == $other->level->rank :
249
-            $this->rank == $other->rank;
245
+            $this->level->rank == $other->level->rank : $this->rank == $other->rank;
250 246
     }
251 247
 
252 248
 
@@ -265,14 +261,13 @@  discard block
 block discarded – undo
265 261
     protected function cacheGetAllPermissions()
266 262
     {
267 263
         $rank = get_class($this) == config('laravel-acl.level') ?
268
-            $this->rank :
269
-            $this->level->rank;
264
+            $this->rank : $this->level->rank;
270 265
 
271 266
         $levels = config('laravel-acl.level', Level::class)::where('rank', '>=', $rank)->with('permissions')->get();
272 267
 
273 268
         $allPerms = new Collection();
274 269
 
275
-        $levels->each(function ($level, $key) use (&$allPerms) {
270
+        $levels->each(function($level, $key) use (&$allPerms) {
276 271
             $allPerms = $allPerms->merge($level->permissions);
277 272
         });
278 273
 
@@ -288,16 +283,14 @@  discard block
 block discarded – undo
288 283
     protected function cacheGetInheritedPermissions()
289 284
     {
290 285
         $rank = get_class($this) == config('laravel-acl.level') ?
291
-            $this->rank :
292
-            $this->level->rank;
286
+            $this->rank : $this->level->rank;
293 287
 
294 288
         $levels = get_class($this) == config('laravel-acl.user') ?
295
-            config('laravel-acl.level', Level::class)::where('rank', '>=', $rank)->with('permissions')->get() :
296
-            config('laravel-acl.level', Level::class)::where('rank', '>', $rank)->with('permissions')->get();
289
+            config('laravel-acl.level', Level::class)::where('rank', '>=', $rank)->with('permissions')->get() : config('laravel-acl.level', Level::class)::where('rank', '>', $rank)->with('permissions')->get();
297 290
 
298 291
         $inheritedPerms = new Collection();
299 292
 
300
-        $levels->each(function ($level, $key) use (&$inheritedPerms) {
293
+        $levels->each(function($level, $key) use (&$inheritedPerms) {
301 294
             $inheritedPerms = $inheritedPerms->merge($level->permissions->load('level'));
302 295
         });
303 296
 
@@ -394,8 +387,7 @@  discard block
 block discarded – undo
394 387
                 $permissionsObjects[$permission->id] = ['negated' => true];
395 388
             } else {
396 389
                 $model == 'User' ?
397
-                    array_push($permissionsObjects, $permission->id) :
398
-                    array_push($permissionsObjects, $permission);
390
+                    array_push($permissionsObjects, $permission->id) : array_push($permissionsObjects, $permission);
399 391
             }
400 392
         }
401 393
 
@@ -431,7 +423,7 @@  discard block
 block discarded – undo
431 423
             $this->permissions()->detach($permissionObjects);
432 424
 
433 425
         if ($model == 'Level') {
434
-            config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function ($permission) {
426
+            config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function($permission) {
435 427
                 return $permission->id;
436 428
             }, $permissionObjects))->update(['level_id' => null]);
437 429
         }
@@ -452,7 +444,7 @@  discard block
 block discarded – undo
452 444
         if ($model == 'Level') {
453 445
             $this->clearPermissions();
454 446
 
455
-            config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function ($permission) {
447
+            config('laravel-acl.permission', Permission::class)::whereIn('id', array_map(function($permission) {
456 448
                 return $permission->id;
457 449
             }, $permissionObjects))
458 450
                 ->update(['level_id' => $this->id]);
Please login to merge, or discard this patch.