@@ -59,26 +59,30 @@ |
||
| 59 | 59 | { |
| 60 | 60 | $actions = []; |
| 61 | 61 | |
| 62 | - if (static::can(RolesPolicy::ability('show'), [$role])) |
|
| 63 | - $actions[] = LinkAction::action('show', route('admin::auth.roles.show', [$role]), false) |
|
| 62 | + if (static::can(RolesPolicy::ability('show'), [$role])) { |
|
| 63 | + $actions[] = LinkAction::action('show', route('admin::auth.roles.show', [$role]), false) |
|
| 64 | 64 | ->size('sm'); |
| 65 | + } |
|
| 65 | 66 | |
| 66 | - if (static::can(RolesPolicy::ability('update'), [$role])) |
|
| 67 | - $actions[] = LinkAction::action('edit', $role->isLocked() ? '#' : route('admin::auth.roles.edit', [$role]), false) |
|
| 67 | + if (static::can(RolesPolicy::ability('update'), [$role])) { |
|
| 68 | + $actions[] = LinkAction::action('edit', $role->isLocked() ? '#' : route('admin::auth.roles.edit', [$role]), false) |
|
| 68 | 69 | ->size('sm') |
| 69 | 70 | ->setDisabled($role->isLocked()); |
| 71 | + } |
|
| 70 | 72 | |
| 71 | - if (static::can(RolesPolicy::ability('activate'), [$role])) |
|
| 72 | - $actions[] = ButtonAction::action($role->isActive() ? 'deactivate' : 'activate', false) |
|
| 73 | + if (static::can(RolesPolicy::ability('activate'), [$role])) { |
|
| 74 | + $actions[] = ButtonAction::action($role->isActive() ? 'deactivate' : 'activate', false) |
|
| 73 | 75 | ->size('sm') |
| 74 | 76 | ->attribute('onclick', "window.Foundation.\$emit('auth::roles.activate', ".json_encode(['id' => $role->getRouteKey(), 'status' => $role->isActive() ? 'activated' : 'deactivated']).")") |
| 75 | 77 | ->setDisabled($role->isLocked()); |
| 78 | + } |
|
| 76 | 79 | |
| 77 | - if (static::can(RolesPolicy::ability('delete'), [$role])) |
|
| 78 | - $actions[] = ButtonAction::action('delete', false) |
|
| 80 | + if (static::can(RolesPolicy::ability('delete'), [$role])) { |
|
| 81 | + $actions[] = ButtonAction::action('delete', false) |
|
| 79 | 82 | ->size('sm') |
| 80 | 83 | ->attributeIf($role->isDeletable(), 'onclick', "window.Foundation.\$emit('auth::roles.delete', ".json_encode(['id' => $role->getRouteKey()]).")") |
| 81 | 84 | ->setDisabled($role->isNotDeletable()); |
| 85 | + } |
|
| 82 | 86 | |
| 83 | 87 | return $actions; |
| 84 | 88 | } |
@@ -59,30 +59,35 @@ |
||
| 59 | 59 | { |
| 60 | 60 | $actions = []; |
| 61 | 61 | |
| 62 | - if (static::can(UsersPolicy::ability('show'), [$user])) |
|
| 63 | - $actions[] = LinkAction::action('show', route('admin::auth.users.show', [$user]), false) |
|
| 62 | + if (static::can(UsersPolicy::ability('show'), [$user])) { |
|
| 63 | + $actions[] = LinkAction::action('show', route('admin::auth.users.show', [$user]), false) |
|
| 64 | 64 | ->size('sm'); |
| 65 | + } |
|
| 65 | 66 | |
| 66 | - if (static::can(UsersPolicy::ability('update'), [$user])) |
|
| 67 | - $actions[] = LinkAction::action('edit', route('admin::auth.users.edit', [$user]), false) |
|
| 67 | + if (static::can(UsersPolicy::ability('update'), [$user])) { |
|
| 68 | + $actions[] = LinkAction::action('edit', route('admin::auth.users.edit', [$user]), false) |
|
| 68 | 69 | ->size('sm'); |
| 70 | + } |
|
| 69 | 71 | |
| 70 | - if (static::can(UsersPolicy::ability('activate'), [$user])) |
|
| 71 | - $actions[] = ButtonAction::action($user->isActive() ? 'deactivate' : 'activate', false) |
|
| 72 | + if (static::can(UsersPolicy::ability('activate'), [$user])) { |
|
| 73 | + $actions[] = ButtonAction::action($user->isActive() ? 'deactivate' : 'activate', false) |
|
| 72 | 74 | ->attributeIf($user->isDeletable(), 'onclick', "Foundation.\$emit('auth::users.activate', ".json_encode(['id' => $user->uuid, 'status' => $user->isActive() ? 'activated' : 'deactivated']).")") |
| 73 | 75 | ->size('sm') |
| 74 | 76 | ->setDisabled($user->isSuperAdmin()); |
| 77 | + } |
|
| 75 | 78 | |
| 76 | - if (static::can(UsersPolicy::ability('restore'), [$user]) && $user->trashed()) |
|
| 77 | - $actions[] = ButtonAction::action('restore', false) |
|
| 79 | + if (static::can(UsersPolicy::ability('restore'), [$user]) && $user->trashed()) { |
|
| 80 | + $actions[] = ButtonAction::action('restore', false) |
|
| 78 | 81 | ->attribute('onclick', "window.Foundation.\$emit('auth::users.restore', ".json_encode(['id' => $user->uuid]).")") |
| 79 | 82 | ->size('sm'); |
| 83 | + } |
|
| 80 | 84 | |
| 81 | - if (static::can(UsersPolicy::ability('delete'), [$user])) |
|
| 82 | - $actions[] = ButtonAction::action('delete', false) |
|
| 85 | + if (static::can(UsersPolicy::ability('delete'), [$user])) { |
|
| 86 | + $actions[] = ButtonAction::action('delete', false) |
|
| 83 | 87 | ->attributeIf($user->isDeletable(), 'onclick', "window.Foundation.\$emit('auth::users.delete', ".json_encode(['id' => $user->uuid]).")") |
| 84 | 88 | ->size('sm') |
| 85 | 89 | ->setDisabled($user->isNotDeletable()); |
| 90 | + } |
|
| 86 | 91 | |
| 87 | 92 | return $actions; |
| 88 | 93 | } |
@@ -31,8 +31,9 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | public function handle($request, Closure $next, $guard = null) |
| 33 | 33 | { |
| 34 | - if (Auth::guard($guard)->check()) |
|
| 35 | - Auth::guard($guard)->user()->updateLastActivity(); |
|
| 34 | + if (Auth::guard($guard)->check()) { |
|
| 35 | + Auth::guard($guard)->user()->updateLastActivity(); |
|
| 36 | + } |
|
| 36 | 37 | |
| 37 | 38 | return $next($request); |
| 38 | 39 | } |
@@ -116,10 +116,11 @@ |
||
| 116 | 116 | $data = $request->getValidatedData(); |
| 117 | 117 | $rolesRepo->update($role, $data); |
| 118 | 118 | |
| 119 | - if (empty($permissions = $data['permissions'] ?: [])) |
|
| 120 | - $rolesRepo->detachAllPermissions($role); |
|
| 121 | - else |
|
| 122 | - $rolesRepo->syncPermissionsByUuids($role, $permissions); |
|
| 119 | + if (empty($permissions = $data['permissions'] ?: [])) { |
|
| 120 | + $rolesRepo->detachAllPermissions($role); |
|
| 121 | + } else { |
|
| 122 | + $rolesRepo->syncPermissionsByUuids($role, $permissions); |
|
| 123 | + } |
|
| 123 | 124 | |
| 124 | 125 | return redirect()->route('admin::auth.roles.show', [$role]); |
| 125 | 126 | } |
@@ -280,8 +280,9 @@ |
||
| 280 | 280 | */ |
| 281 | 281 | $authUser = auth()->user(); |
| 282 | 282 | |
| 283 | - if ($impersonator->start($authUser, $user)) |
|
| 284 | - return redirect()->route('public::index'); |
|
| 283 | + if ($impersonator->start($authUser, $user)) { |
|
| 284 | + return redirect()->route('public::index'); |
|
| 285 | + } |
|
| 285 | 286 | |
| 286 | 287 | $this->notifyError( |
| 287 | 288 | __('Impersonation Not Allowed'), |
@@ -177,8 +177,9 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function activate(User $user) |
| 179 | 179 | { |
| 180 | - if ($user->isActive()) |
|
| 181 | - return false; |
|
| 180 | + if ($user->isActive()) { |
|
| 181 | + return false; |
|
| 182 | + } |
|
| 182 | 183 | |
| 183 | 184 | event(new ActivatingUser($user)); |
| 184 | 185 | $result = $user->forceFill(['activated_at' => $user->freshTimestamp()])->save(); |
@@ -196,8 +197,9 @@ discard block |
||
| 196 | 197 | */ |
| 197 | 198 | public function deactivate(User $user): bool |
| 198 | 199 | { |
| 199 | - if ( ! $user->isActive()) |
|
| 200 | - return false; |
|
| 200 | + if ( ! $user->isActive()) { |
|
| 201 | + return false; |
|
| 202 | + } |
|
| 201 | 203 | |
| 202 | 204 | event(new DeactivatingUser($user)); |
| 203 | 205 | $result = $user->forceFill(['activated_at' => null])->save(); |
@@ -270,8 +272,9 @@ discard block |
||
| 270 | 272 | */ |
| 271 | 273 | public function syncRoles(User $user, Collection $roles): array |
| 272 | 274 | { |
| 273 | - if (empty($roles)) |
|
| 274 | - return []; |
|
| 275 | + if (empty($roles)) { |
|
| 276 | + return []; |
|
| 277 | + } |
|
| 275 | 278 | |
| 276 | 279 | event(new SyncingRolesToUser($user, $roles)); |
| 277 | 280 | $synced = $user->roles()->sync($roles->pluck('id')); |
@@ -173,8 +173,9 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function syncPermissionsByIds(Role $role, array $ids): array |
| 175 | 175 | { |
| 176 | - if (empty($ids)) |
|
| 177 | - return []; |
|
| 176 | + if (empty($ids)) { |
|
| 177 | + return []; |
|
| 178 | + } |
|
| 178 | 179 | |
| 179 | 180 | event(new SyncingPermissionsToRole($role, $ids)); |
| 180 | 181 | $synced = $role->permissions()->sync($ids); |
@@ -294,8 +295,9 @@ discard block |
||
| 294 | 295 | public function getFilteredByAuthenticatedUser(User $user): iterable |
| 295 | 296 | { |
| 296 | 297 | return $this->get()->filter(function (Role $role) use ($user) { |
| 297 | - if ($user->isSuperAdmin()) |
|
| 298 | - return false; |
|
| 298 | + if ($user->isSuperAdmin()) { |
|
| 299 | + return false; |
|
| 300 | + } |
|
| 299 | 301 | |
| 300 | 302 | return $role->key !== Role::ADMINISTRATOR; |
| 301 | 303 | }); |
@@ -38,8 +38,9 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | public function up(): void |
| 40 | 40 | { |
| 41 | - if ( ! Auth::config('throttles.enabled', false)) |
|
| 42 | - return; |
|
| 41 | + if ( ! Auth::config('throttles.enabled', false)) { |
|
| 42 | + return; |
|
| 43 | + } |
|
| 43 | 44 | |
| 44 | 45 | $this->createSchema(function (Blueprint $table) { |
| 45 | 46 | $table->increments('id'); |