@@ -34,7 +34,7 @@ |
||
| 34 | 34 | public function calculate(Request $request, RolesRepository $repo) |
| 35 | 35 | { |
| 36 | 36 | // Calculate roles with users count |
| 37 | - $result = $repo->withCount(['administrators'])->get()->filter(function ($role) { |
|
| 37 | + $result = $repo->withCount(['administrators'])->get()->filter(function($role) { |
|
| 38 | 38 | return $role->administrators_count > 0; |
| 39 | 39 | })->pluck('administrators_count', 'name'); |
| 40 | 40 | |
@@ -111,7 +111,7 @@ |
||
| 111 | 111 | 'password' => null, |
| 112 | 112 | ]; |
| 113 | 113 | |
| 114 | - return tap($this->getUsersRepository()->createOne($attributes), function ($user) { |
|
| 114 | + return tap($this->getUsersRepository()->createOne($attributes), function($user) { |
|
| 115 | 115 | event(new UserRegistered($user)); |
| 116 | 116 | }); |
| 117 | 117 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function onlyTrashed(bool $condition = true) |
| 76 | 76 | { |
| 77 | - return $this->when($condition, function (Builder $query) { |
|
| 77 | + return $this->when($condition, function(Builder $query) { |
|
| 78 | 78 | return $query->onlyTrashed(); |
| 79 | 79 | }); |
| 80 | 80 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $attributes['password'] = Str::random(8); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - return tap($this->model()->fill($attributes), function (User $user) use ($attributes) { |
|
| 114 | + return tap($this->model()->fill($attributes), function(User $user) use ($attributes) { |
|
| 115 | 115 | $user->forceFill([ |
| 116 | 116 | 'uuid' => $attributes['uuid'] ?? Str::uuid(), |
| 117 | 117 | 'activated_at' => $attributes['activated_at'] ?? now(), // TODO: Add a setting to change this |
@@ -160,8 +160,9 @@ discard block |
||
| 160 | 160 | foreach ($model->getDirty() as $name => $value) { |
| 161 | 161 | $event = $name.'.'.$type; |
| 162 | 162 | |
| 163 | - if ( ! array_key_exists($event, $attributesEvents)) |
|
| 164 | - continue; |
|
| 163 | + if ( ! array_key_exists($event, $attributesEvents)) { |
|
| 164 | + continue; |
|
| 165 | + } |
|
| 165 | 166 | |
| 166 | 167 | return in_array($name, $model->getHidden()) |
| 167 | 168 | ? event(new $attributesEvents[$event]($model)) |
@@ -214,8 +215,9 @@ discard block |
||
| 214 | 215 | */ |
| 215 | 216 | public function activateOne(User $user) |
| 216 | 217 | { |
| 217 | - if ($user->isActive()) |
|
| 218 | - return false; |
|
| 218 | + if ($user->isActive()) { |
|
| 219 | + return false; |
|
| 220 | + } |
|
| 219 | 221 | |
| 220 | 222 | event(new ActivatingUser($user)); |
| 221 | 223 | $result = $user->forceFill(['activated_at' => $user->freshTimestamp()])->save(); |
@@ -233,8 +235,9 @@ discard block |
||
| 233 | 235 | */ |
| 234 | 236 | public function deactivateOne(User $user): bool |
| 235 | 237 | { |
| 236 | - if ( ! $user->isActive()) |
|
| 237 | - return false; |
|
| 238 | + if ( ! $user->isActive()) { |
|
| 239 | + return false; |
|
| 240 | + } |
|
| 238 | 241 | |
| 239 | 242 | event(new DeactivatingUser($user)); |
| 240 | 243 | $result = $user->forceFill(['activated_at' => null])->save(); |
@@ -264,8 +267,9 @@ discard block |
||
| 264 | 267 | */ |
| 265 | 268 | public function restoreOne(User $user) |
| 266 | 269 | { |
| 267 | - if ( ! $user->trashed()) |
|
| 268 | - return null; |
|
| 270 | + if ( ! $user->trashed()) { |
|
| 271 | + return null; |
|
| 272 | + } |
|
| 269 | 273 | |
| 270 | 274 | return $user->restore(); |
| 271 | 275 | } |
@@ -193,8 +193,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function createOne(array $attributes): Role |
| 150 | 150 | { |
| 151 | - return tap($this->create($attributes), function (Role $role) use ($attributes) { |
|
| 151 | + return tap($this->create($attributes), function(Role $role) use ($attributes) { |
|
| 152 | 152 | $this->syncPermissionsByUuids($role, $attributes['permissions'] ?: []); |
| 153 | 153 | }); |
| 154 | 154 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | { |
| 179 | 179 | $updated = $this->updateOne($role, $attributes); |
| 180 | 180 | |
| 181 | - tap($attributes['permissions'] ?: [], function (array $permissions) use ($role) { |
|
| 181 | + tap($attributes['permissions'] ?: [], function(array $permissions) use ($role) { |
|
| 182 | 182 | empty($permissions) |
| 183 | 183 | ? $this->detachAllPermissions($role) |
| 184 | 184 | : $this->syncPermissionsByUuids($role, $permissions); |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | if ($admin->isSuperAdmin()) |
| 379 | 379 | return $roles; |
| 380 | 380 | |
| 381 | - return $roles->reject(function (Role $role) { |
|
| 381 | + return $roles->reject(function(Role $role) { |
|
| 382 | 382 | return $role->isAdministrator(); |
| 383 | 383 | }); |
| 384 | 384 | } |
@@ -59,7 +59,7 @@ |
||
| 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 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -146,8 +146,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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')); |
@@ -54,11 +54,13 @@ |
||
| 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, |
@@ -62,7 +62,7 @@ |
||
| 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(); |
@@ -32,7 +32,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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'] ?? []; |
@@ -65,14 +65,17 @@ |
||
| 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 | |