Passed
Pull Request — master (#14)
by ARCANEDEV
05:47
created
src/Authorization/Repositories/RolesRepository.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public function createOne(array $attributes): Role
143 143
     {
144
-        return tap($this->create($attributes), function (Role $role) use ($attributes) {
144
+        return tap($this->create($attributes), function(Role $role) use ($attributes) {
145 145
             $this->syncPermissionsByUuids($role, $attributes['permissions'] ?: []);
146 146
         });
147 147
     }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         if ($admin->isSuperAdmin())
311 311
             return $roles;
312 312
 
313
-        return $roles->reject(function (Role $role) {
313
+        return $roles->reject(function(Role $role) {
314 314
             return $role->isAdministrator();
315 315
         });
316 316
     }
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -193,8 +193,9 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function syncPermissionsByIds(Role $role, array $ids): array
195 195
     {
196
-        if (empty($ids))
197
-            return [];
196
+        if (empty($ids)) {
197
+                    return [];
198
+        }
198 199
 
199 200
         event(new SyncingPermissions($role, $ids));
200 201
         $synced = $role->permissions()->sync($ids);
@@ -302,8 +303,9 @@  discard block
 block discarded – undo
302 303
      */
303 304
     public function activateOne(Role $role): bool
304 305
     {
305
-        if ($role->isActive())
306
-            return false;
306
+        if ($role->isActive()) {
307
+                    return false;
308
+        }
307 309
 
308 310
         event(new ActivatingRole($role));
309 311
         $result = $role->forceFill(['activated_at' => $role->freshTimestamp()])->save();
@@ -321,8 +323,9 @@  discard block
 block discarded – undo
321 323
      */
322 324
     public function deactivateOne(Role $role): bool
323 325
     {
324
-        if ( ! $role->isActive())
325
-            return false;
326
+        if ( ! $role->isActive()) {
327
+                    return false;
328
+        }
326 329
 
327 330
         event(new DeactivatingRole($role));
328 331
         $result = $role->forceFill(['activated_at' => null])->save();
@@ -354,8 +357,9 @@  discard block
 block discarded – undo
354 357
     {
355 358
         $roles = $this->get();
356 359
 
357
-        if ($admin->isSuperAdmin())
358
-            return $roles;
360
+        if ($admin->isSuperAdmin()) {
361
+                    return $roles;
362
+        }
359 363
 
360 364
         return $roles->reject(function (Role $role) {
361 365
             return $role->isAdministrator();
Please login to merge, or discard this patch.
src/Authorization/Repositories/PermissionsGroupsRepository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
      */
60 60
     public function createOneWithPermissions(array $attributes, iterable $permissions)
61 61
     {
62
-        return tap($this->createOne($attributes), function (PermissionsGroup $group) use ($permissions) {
62
+        return tap($this->createOne($attributes), function(PermissionsGroup $group) use ($permissions) {
63 63
             $group->permissions()->saveMany($permissions);
64 64
         });
65 65
     }
Please login to merge, or discard this patch.
src/Authorization/Repositories/AdministratorsRepository.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function onlyTrashed(bool $condition = true)
78 78
     {
79
-        return $this->when($condition, function (Builder $q) {
79
+        return $this->when($condition, function(Builder $q) {
80 80
             return $q->onlyTrashed();
81 81
         });
82 82
     }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     {
113 113
         $attributes['password'] = $attributes['password'] ?? Str::random(8);
114 114
 
115
-        return tap($this->model()->fill($attributes), function (Administrator $administrator) use ($attributes) {
115
+        return tap($this->model()->fill($attributes), function(Administrator $administrator) use ($attributes) {
116 116
             $administrator->forceFill([
117 117
                 'activated_at' => $attributes['activated_at'] ?? now(), // TODO: Add a setting to change this
118 118
             ]);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     {
133 133
         $roles = $attributes['roles'];
134 134
 
135
-        return tap($this->createOne($attributes), function ($administrator) use ($roles) {
135
+        return tap($this->createOne($attributes), function($administrator) use ($roles) {
136 136
             $this->syncRolesByUuids($administrator, $roles);
137 137
         });
138 138
     }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     {
166 166
         $roles = $attributes['roles'];
167 167
 
168
-        return tap($this->updateOne($administrator, $attributes), function () use ($administrator, $roles) {
168
+        return tap($this->updateOne($administrator, $attributes), function() use ($administrator, $roles) {
169 169
             $this->syncRolesByUuids($administrator, $roles);
170 170
         });
171 171
     }
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -146,8 +146,9 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public function updateOne(Administrator $administrator, array $attributes): bool
148 148
     {
149
-        if ( ! $administrator->exists)
150
-            return false;
149
+        if ( ! $administrator->exists) {
150
+                    return false;
151
+        }
151 152
 
152 153
         return $administrator->fill($attributes)->save();
153 154
     }
@@ -209,8 +210,9 @@  discard block
 block discarded – undo
209 210
      */
210 211
     public function activateOne(Administrator $administrator)
211 212
     {
212
-        if ($administrator->isActive())
213
-            return false;
213
+        if ($administrator->isActive()) {
214
+                    return false;
215
+        }
214 216
 
215 217
         event(new ActivatingAdministrator($administrator));
216 218
         $result = $administrator->forceFill(['activated_at' => $administrator->freshTimestamp()])->save();
@@ -228,8 +230,9 @@  discard block
 block discarded – undo
228 230
      */
229 231
     public function deactivateOne(Administrator $administrator): bool
230 232
     {
231
-        if ( ! $administrator->isActive())
232
-            return false;
233
+        if ( ! $administrator->isActive()) {
234
+                    return false;
235
+        }
233 236
 
234 237
         event(new DeactivatingAdministrator($administrator));
235 238
         $result = $administrator->forceFill(['activated_at' => null])->save();
@@ -302,8 +305,9 @@  discard block
 block discarded – undo
302 305
      */
303 306
     public function syncRoles(Administrator $administrator, Collection $roles): array
304 307
     {
305
-        if (empty($roles))
306
-            return [];
308
+        if (empty($roles)) {
309
+                    return [];
310
+        }
307 311
 
308 312
         event(new SyncingRoles($administrator, $roles));
309 313
         $synced = $administrator->roles()->sync($roles->pluck('id'));
Please login to merge, or discard this patch.
src/Authorization/Listeners/Sessions/UpdateUserLastActivity.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,11 +54,13 @@
 block discarded – undo
54 54
     {
55 55
         $session = $event->session;
56 56
 
57
-        if ($session->isVisitor())
58
-            return;
57
+        if ($session->isVisitor()) {
58
+                    return;
59
+        }
59 60
 
60
-        if ( ! $session->isSameUser($authenticated = $this->getAuthenticated()))
61
-            return;
61
+        if ( ! $session->isSameUser($authenticated = $this->getAuthenticated())) {
62
+                    return;
63
+        }
62 64
 
63 65
         $authenticated->forceFill([
64 66
             'last_activity_at' => $session->last_activity_at,
Please login to merge, or discard this patch.
src/Authorization/Rules/Users/UniqueKey.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/Authorization/Socialite.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $providers = Auth::config('authentication.socialite.providers', []);
34 34
 
35
-        return Collection::make($providers)->transform(function (array $provider, string $key) {
35
+        return Collection::make($providers)->transform(function(array $provider, string $key) {
36 36
             return new SocialiteProvider(array_merge($provider, ['type' => $key]));
37 37
         });
38 38
     }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public static function getEnabledProviders(): Collection
46 46
     {
47
-        return static::getProviders()->filter(function (SocialiteProvider $provider) {
47
+        return static::getProviders()->filter(function(SocialiteProvider $provider) {
48 48
             return $provider->enabled ?? false;
49 49
         });
50 50
     }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $options = config("services.{$provider}", []);
62 62
 
63
-        return tap(static::driver($provider), function (Provider $socialite) use ($provider, $options) {
63
+        return tap(static::driver($provider), function(Provider $socialite) use ($provider, $options) {
64 64
             $scopes = $options['scopes'] ?? [];
65 65
             $with   = $options['with'] ?? [];
66 66
             $fields = $options['fields'] ?? [];
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -65,14 +65,17 @@
 block discarded – undo
65 65
             $with   = $options['with'] ?? [];
66 66
             $fields = $options['fields'] ?? [];
67 67
 
68
-            if ( ! empty($scopes))
69
-                $socialite->scopes($scopes);
68
+            if ( ! empty($scopes)) {
69
+                            $socialite->scopes($scopes);
70
+            }
70 71
 
71
-            if ( ! empty($with))
72
-                $socialite->with($with);
72
+            if ( ! empty($with)) {
73
+                            $socialite->with($with);
74
+            }
73 75
 
74
-            if ( ! empty($fields))
75
-                $socialite->fields($fields);
76
+            if ( ! empty($fields)) {
77
+                            $socialite->fields($fields);
78
+            }
76 79
         })->redirect();
77 80
     }
78 81
 
Please login to merge, or discard this patch.
src/Authorization/Http/Controllers/RolesController.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -170,10 +170,11 @@
 block discarded – undo
170 170
 
171 171
         $rolesRepo->updateOne($role, $data);
172 172
 
173
-        if (empty($permissions = $data['permissions'] ?: []))
174
-            $rolesRepo->detachAllPermissions($role);
175
-        else
176
-            $rolesRepo->syncPermissionsByUuids($role, $permissions);
173
+        if (empty($permissions = $data['permissions'] ?: [])) {
174
+                    $rolesRepo->detachAllPermissions($role);
175
+        } else {
176
+                    $rolesRepo->syncPermissionsByUuids($role, $permissions);
177
+        }
177 178
 
178 179
         return redirect()->route('admin::authorization.roles.show', [$role]);
179 180
     }
Please login to merge, or discard this patch.
src/Authorization/Http/Routes/WebRoutes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
      */
44 44
     public function map(): void
45 45
     {
46
-        $this->adminGroup(function () {
46
+        $this->adminGroup(function() {
47 47
             static::mapRouteClasses($this->getRouteClasses());
48 48
         });
49 49
     }
Please login to merge, or discard this patch.
src/Authorization/Http/Routes/Web/AdministratorsRoutes.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -34,56 +34,56 @@
 block discarded – undo
34 34
         $this->name('administrators.')->prefix('administrators')->group(function () {
35 35
             // admin::auth.administrators.index
36 36
             $this->get('/', [AdministratorsController::class, 'index'])
37
-                 ->name('index');
37
+                    ->name('index');
38 38
 
39 39
             // admin::auth.administrators.trash
40 40
             $this->get('trash', [AdministratorsController::class, 'trash'])
41
-                 ->name('trash');
41
+                    ->name('trash');
42 42
 
43 43
             // admin::auth.administrators.metrics
44 44
             $this->get('metrics', [AdministratorsController::class, 'metrics'])
45
-                 ->name('metrics');
45
+                    ->name('metrics');
46 46
 
47 47
             // admin::auth.administrators.create
48 48
             $this->get('create', [AdministratorsController::class, 'create'])
49
-                 ->name('create');
49
+                    ->name('create');
50 50
 
51 51
             // admin::auth.administrators.post
52 52
             $this->post('store', [AdministratorsController::class, 'store'])
53
-                 ->name('store');
53
+                    ->name('store');
54 54
 
55 55
             $this->prefix('{'.static::WILDCARD_ADMIN.'}')->group(function () {
56 56
                 // admin::auth.administrators.show
57 57
                 $this->get('/', [AdministratorsController::class, 'show'])
58
-                     ->name('show');
58
+                        ->name('show');
59 59
 
60 60
                 // admin::auth.administrators.edit
61 61
                 $this->get('edit', [AdministratorsController::class, 'edit'])
62
-                     ->name('edit');
62
+                        ->name('edit');
63 63
 
64 64
                 // admin::auth.administrators.update
65 65
                 $this->put('update', [AdministratorsController::class, 'update'])
66
-                     ->name('update');
66
+                        ->name('update');
67 67
 
68 68
                 // admin::auth.administrators.activate
69 69
                 $this->put('activate', [AdministratorsController::class, 'activate'])
70
-                     ->middleware(['ajax'])
71
-                     ->name('activate');
70
+                        ->middleware(['ajax'])
71
+                        ->name('activate');
72 72
 
73 73
                 // admin::auth.administrators.deactivate
74 74
                 $this->put('deactivate', [AdministratorsController::class, 'deactivate'])
75
-                     ->middleware(['ajax'])
76
-                     ->name('deactivate');
75
+                        ->middleware(['ajax'])
76
+                        ->name('deactivate');
77 77
 
78 78
                 // admin::auth.administrators.delete
79 79
                 $this->delete('delete', [AdministratorsController::class, 'delete'])
80
-                     ->middleware(['ajax'])
81
-                     ->name('delete');
80
+                        ->middleware(['ajax'])
81
+                        ->name('delete');
82 82
 
83 83
                 // admin::auth.administrators.restore
84 84
                 $this->put('restore', [AdministratorsController::class, 'restore'])
85
-                     ->middleware(['ajax'])
86
-                     ->name('restore');
85
+                        ->middleware(['ajax'])
86
+                        ->name('restore');
87 87
 
88 88
                 static::mapRouteClasses([
89 89
                     Administrators\SessionsRoutes::class
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function map(): void
33 33
     {
34
-        $this->name('administrators.')->prefix('administrators')->group(function () {
34
+        $this->name('administrators.')->prefix('administrators')->group(function() {
35 35
             // admin::auth.administrators.index
36 36
             $this->get('/', [AdministratorsController::class, 'index'])
37 37
                  ->name('index');
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             $this->post('store', [AdministratorsController::class, 'store'])
53 53
                  ->name('store');
54 54
 
55
-            $this->prefix('{'.static::WILDCARD_ADMIN.'}')->group(function () {
55
+            $this->prefix('{'.static::WILDCARD_ADMIN.'}')->group(function() {
56 56
                 // admin::auth.administrators.show
57 57
                 $this->get('/', [AdministratorsController::class, 'show'])
58 58
                      ->name('show');
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function bindings(AdministratorsRepository $repo): void
101 101
     {
102
-        $this->bind(static::WILDCARD_ADMIN, function (string $uuid) use ($repo) {
102
+        $this->bind(static::WILDCARD_ADMIN, function(string $uuid) use ($repo) {
103 103
             return $repo->firstWhereUuidOrFail($uuid);
104 104
         });
105 105
 
Please login to merge, or discard this patch.