@@ -75,10 +75,10 @@ |
||
75 | 75 | { |
76 | 76 | return $repo |
77 | 77 | ->withCount(['administrators']) |
78 | - ->unless(empty($this->search), function (Builder $query) { |
|
78 | + ->unless(empty($this->search), function(Builder $query) { |
|
79 | 79 | $query->where('name', 'like', '%'.$this->search.'%'); |
80 | 80 | }) |
81 | - ->unless(empty($this->sortField), function (Builder $query) { |
|
81 | + ->unless(empty($this->sortField), function(Builder $query) { |
|
82 | 82 | $query->orderBy($this->sortField, $this->getSortDirection()); |
83 | 83 | }) |
84 | 84 | ->paginate($this->perPage); |
@@ -30,7 +30,7 @@ |
||
30 | 30 | */ |
31 | 31 | public function getUsersCountAttribute(): int |
32 | 32 | { |
33 | - return $this->roles->sum(function (Role $role) { |
|
33 | + return $this->roles->sum(function(Role $role) { |
|
34 | 34 | return $role->administrators->count(); |
35 | 35 | }); |
36 | 36 | } |
@@ -96,7 +96,7 @@ |
||
96 | 96 | $show = 2; |
97 | 97 | $parts = explode('@', $this->email); |
98 | 98 | |
99 | - return substr($parts[0],0, $show).str_repeat('*', 3).'@'.$parts[1]; |
|
99 | + return substr($parts[0], 0, $show).str_repeat('*', 3).'@'.$parts[1]; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -34,8 +34,9 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function getDisplayNameAttribute(): string |
36 | 36 | { |
37 | - if ($this->hasName()) |
|
38 | - return $this->getFullNameAttribute(); |
|
37 | + if ($this->hasName()) { |
|
38 | + return $this->getFullNameAttribute(); |
|
39 | + } |
|
39 | 40 | |
40 | 41 | return $this->username; |
41 | 42 | } |
@@ -57,8 +58,9 @@ discard block |
||
57 | 58 | */ |
58 | 59 | public function setFirstNameAttribute($firstName) |
59 | 60 | { |
60 | - if (is_null($firstName)) |
|
61 | - return; |
|
61 | + if (is_null($firstName)) { |
|
62 | + return; |
|
63 | + } |
|
62 | 64 | |
63 | 65 | $this->attributes['first_name'] = Str::title(Str::lower($firstName)); |
64 | 66 | } |
@@ -70,8 +72,9 @@ discard block |
||
70 | 72 | */ |
71 | 73 | public function setLastNameAttribute($lastName) |
72 | 74 | { |
73 | - if (is_null($lastName)) |
|
74 | - return; |
|
75 | + if (is_null($lastName)) { |
|
76 | + return; |
|
77 | + } |
|
75 | 78 | |
76 | 79 | $this->attributes['last_name'] = Str::upper($lastName); |
77 | 80 | } |
@@ -135,8 +138,9 @@ discard block |
||
135 | 138 | */ |
136 | 139 | public function getLastActivityAttribute(): string |
137 | 140 | { |
138 | - if (is_null($this->last_activity_at)) |
|
139 | - return __('No recent activity'); |
|
141 | + if (is_null($this->last_activity_at)) { |
|
142 | + return __('No recent activity'); |
|
143 | + } |
|
140 | 144 | |
141 | 145 | return $this->last_activity_at->diffForHumans(); |
142 | 146 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | return $this->active_roles |
166 | 166 | ->pluck('permissions') |
167 | 167 | ->flatten() |
168 | - ->unique(function (Permission $permission) { |
|
168 | + ->unique(function(Permission $permission) { |
|
169 | 169 | return $permission->getKey(); |
170 | 170 | }); |
171 | 171 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function may($ability): bool |
211 | 211 | { |
212 | - return $this->permissions->filter(function (Permission $permission) use ($ability) { |
|
212 | + return $this->permissions->filter(function(Permission $permission) use ($ability) { |
|
213 | 213 | return $permission->hasAbility($ability); |
214 | 214 | })->isNotEmpty(); |
215 | 215 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | ? $permissions |
229 | 229 | : $this->newCollection($permissions); |
230 | 230 | |
231 | - $failed = $permissions->reject(function ($permission) { |
|
231 | + $failed = $permissions->reject(function($permission) { |
|
232 | 232 | return $this->may($permission); |
233 | 233 | })->values(); |
234 | 234 |
@@ -287,8 +287,9 @@ discard block |
||
287 | 287 | */ |
288 | 288 | public function canImpersonate(): bool |
289 | 289 | { |
290 | - if ( ! impersonator()->isEnabled()) |
|
291 | - return false; |
|
290 | + if ( ! impersonator()->isEnabled()) { |
|
291 | + return false; |
|
292 | + } |
|
292 | 293 | |
293 | 294 | return $this->isSuperAdmin(); |
294 | 295 | } |
@@ -300,8 +301,9 @@ discard block |
||
300 | 301 | */ |
301 | 302 | public function canBeImpersonated(): bool |
302 | 303 | { |
303 | - if ( ! impersonator()->isEnabled()) |
|
304 | - return false; |
|
304 | + if ( ! impersonator()->isEnabled()) { |
|
305 | + return false; |
|
306 | + } |
|
305 | 307 | |
306 | 308 | return false; |
307 | 309 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function getActiveRolesAttribute() |
44 | 44 | { |
45 | - return $this->roles->filter(function (Role $role) { |
|
45 | + return $this->roles->filter(function(Role $role) { |
|
46 | 46 | return $role->isActive(); |
47 | 47 | }); |
48 | 48 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | { |
94 | 94 | $roles = is_array($roles) ? new Collection($roles) : $roles; |
95 | 95 | |
96 | - $failed = $roles->reject(function ($role) { |
|
96 | + $failed = $roles->reject(function($role) { |
|
97 | 97 | return $this->hasRoleKey($role); |
98 | 98 | })->values(); |
99 | 99 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function hasRoleKey(string $key): bool |
111 | 111 | { |
112 | - return $this->active_roles->filter(function (Role $role) use ($key) { |
|
112 | + return $this->active_roles->filter(function(Role $role) use ($key) { |
|
113 | 113 | return $role->hasKey($key); |
114 | 114 | })->isNotEmpty(); |
115 | 115 | } |
@@ -28,8 +28,9 @@ |
||
28 | 28 | */ |
29 | 29 | public function setPasswordAttribute($password) |
30 | 30 | { |
31 | - if (is_null($password)) |
|
32 | - return; |
|
31 | + if (is_null($password)) { |
|
32 | + return; |
|
33 | + } |
|
33 | 34 | |
34 | 35 | $this->attributes['password'] = Hash::make($password); |
35 | 36 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function scopeFilterByAuthenticatedAdministrator(Builder $query, Administrator $administrator): Builder |
167 | 167 | { |
168 | - return $query->unless($administrator->isSuperAdmin(), function (Builder $q) { |
|
168 | + return $query->unless($administrator->isSuperAdmin(), function(Builder $q) { |
|
169 | 169 | $q->where('key', '!=', static::ADMINISTRATOR); |
170 | 170 | }); |
171 | 171 | } |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | if ( ! $this->isActive()) |
370 | 370 | return false; |
371 | 371 | |
372 | - return $this->permissions->filter(function (Permission $permission) use ($ability) { |
|
372 | + return $this->permissions->filter(function(Permission $permission) use ($ability) { |
|
373 | 373 | return $permission->hasAbility($ability); |
374 | 374 | })->first() !== null; |
375 | 375 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | { |
387 | 387 | $permissions = is_array($permissions) ? collect($permissions) : $permissions; |
388 | 388 | |
389 | - $failed = $permissions->reject(function ($permission) { |
|
389 | + $failed = $permissions->reject(function($permission) { |
|
390 | 390 | return $this->can($permission); |
391 | 391 | })->values(); |
392 | 392 |
@@ -273,8 +273,9 @@ discard block |
||
273 | 273 | */ |
274 | 274 | public function attachUser($administrator, bool $reload = true): void |
275 | 275 | { |
276 | - if ($this->hasAdministrator($administrator)) |
|
277 | - return; |
|
276 | + if ($this->hasAdministrator($administrator)) { |
|
277 | + return; |
|
278 | + } |
|
278 | 279 | |
279 | 280 | event(new AttachingAdministrator($this, $administrator)); |
280 | 281 | $this->administrators()->attach($administrator); |
@@ -314,8 +315,9 @@ discard block |
||
314 | 315 | */ |
315 | 316 | public function attachPermission($permission, bool $reload = true): void |
316 | 317 | { |
317 | - if ($this->hasPermission($permission)) |
|
318 | - return; |
|
318 | + if ($this->hasPermission($permission)) { |
|
319 | + return; |
|
320 | + } |
|
319 | 321 | |
320 | 322 | event(new AttachingPermission($this, $permission)); |
321 | 323 | $this->permissions()->attach($permission); |
@@ -366,8 +368,9 @@ discard block |
||
366 | 368 | */ |
367 | 369 | public function can(string $ability): bool |
368 | 370 | { |
369 | - if ( ! $this->isActive()) |
|
370 | - return false; |
|
371 | + if ( ! $this->isActive()) { |
|
372 | + return false; |
|
373 | + } |
|
371 | 374 | |
372 | 375 | return $this->permissions->filter(function (Permission $permission) use ($ability) { |
373 | 376 | return $permission->hasAbility($ability); |
@@ -142,8 +142,9 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function show(Administrator $administrator, Administrator $model = null) |
144 | 144 | { |
145 | - if ($model && $model->isSuperAdmin() && ! $administrator->isSuperAdmin()) |
|
146 | - return false; |
|
145 | + if ($model && $model->isSuperAdmin() && ! $administrator->isSuperAdmin()) { |
|
146 | + return false; |
|
147 | + } |
|
147 | 148 | } |
148 | 149 | |
149 | 150 | /** |
@@ -181,11 +182,13 @@ discard block |
||
181 | 182 | */ |
182 | 183 | public function activate(Administrator $administrator, Administrator $model = null) |
183 | 184 | { |
184 | - if ($administrator->is($model)) |
|
185 | - return false; |
|
185 | + if ($administrator->is($model)) { |
|
186 | + return false; |
|
187 | + } |
|
186 | 188 | |
187 | - if ( ! is_null($model) && $model->isSuperAdmin()) |
|
188 | - return false; |
|
189 | + if ( ! is_null($model) && $model->isSuperAdmin()) { |
|
190 | + return false; |
|
191 | + } |
|
189 | 192 | } |
190 | 193 | |
191 | 194 | /** |
@@ -198,11 +201,13 @@ discard block |
||
198 | 201 | */ |
199 | 202 | public function delete(Administrator $administrator, Administrator $model = null) |
200 | 203 | { |
201 | - if ($administrator->is($model)) |
|
202 | - return false; |
|
204 | + if ($administrator->is($model)) { |
|
205 | + return false; |
|
206 | + } |
|
203 | 207 | |
204 | - if ( ! is_null($model)) |
|
205 | - return $model->isDeletable(); |
|
208 | + if ( ! is_null($model)) { |
|
209 | + return $model->isDeletable(); |
|
210 | + } |
|
206 | 211 | } |
207 | 212 | |
208 | 213 | /** |
@@ -215,8 +220,9 @@ discard block |
||
215 | 220 | */ |
216 | 221 | public function forceDelete(Administrator $administrator, Administrator $model = null) |
217 | 222 | { |
218 | - if ( ! is_null($model)) |
|
219 | - return $model->isDeletable(); |
|
223 | + if ( ! is_null($model)) { |
|
224 | + return $model->isDeletable(); |
|
225 | + } |
|
220 | 226 | } |
221 | 227 | |
222 | 228 | /** |
@@ -229,7 +235,8 @@ discard block |
||
229 | 235 | */ |
230 | 236 | public function restore(Administrator $administrator, Administrator $model = null) |
231 | 237 | { |
232 | - if ( ! is_null($model)) |
|
233 | - return $model->trashed(); |
|
238 | + if ( ! is_null($model)) { |
|
239 | + return $model->trashed(); |
|
240 | + } |
|
234 | 241 | } |
235 | 242 | } |
@@ -124,8 +124,9 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function show(Administrator $administrator, Role $role = null) |
126 | 126 | { |
127 | - if ($role && $role->isAdministrator() && ! $administrator->isSuperAdmin()) |
|
128 | - return false; |
|
127 | + if ($role && $role->isAdministrator() && ! $administrator->isSuperAdmin()) { |
|
128 | + return false; |
|
129 | + } |
|
129 | 130 | } |
130 | 131 | |
131 | 132 | /** |
@@ -150,8 +151,9 @@ discard block |
||
150 | 151 | */ |
151 | 152 | public function update(Administrator $administrator, Role $role = null) |
152 | 153 | { |
153 | - if (static::isRoleLocked($role)) |
|
154 | - return false; |
|
154 | + if (static::isRoleLocked($role)) { |
|
155 | + return false; |
|
156 | + } |
|
155 | 157 | } |
156 | 158 | |
157 | 159 | /** |
@@ -164,8 +166,9 @@ discard block |
||
164 | 166 | */ |
165 | 167 | public function activate(Administrator $administrator, Role $role = null) |
166 | 168 | { |
167 | - if (static::isRoleLocked($role)) |
|
168 | - return false; |
|
169 | + if (static::isRoleLocked($role)) { |
|
170 | + return false; |
|
171 | + } |
|
169 | 172 | } |
170 | 173 | |
171 | 174 | /** |
@@ -178,8 +181,9 @@ discard block |
||
178 | 181 | */ |
179 | 182 | public function delete(Administrator $administrator, Role $role = null) |
180 | 183 | { |
181 | - if ( ! is_null($role)) |
|
182 | - return $role->isDeletable(); |
|
184 | + if ( ! is_null($role)) { |
|
185 | + return $role->isDeletable(); |
|
186 | + } |
|
183 | 187 | } |
184 | 188 | |
185 | 189 | /** |
@@ -193,8 +197,9 @@ discard block |
||
193 | 197 | */ |
194 | 198 | public function detachAdministrator(Administrator $administrator, Role $role = null, Administrator $model = null) |
195 | 199 | { |
196 | - if ( ! $administrator->isSuperAdmin() && $model->isSuperAdmin()) |
|
197 | - return false; |
|
200 | + if ( ! $administrator->isSuperAdmin() && $model->isSuperAdmin()) { |
|
201 | + return false; |
|
202 | + } |
|
198 | 203 | } |
199 | 204 | |
200 | 205 | /** |
@@ -208,8 +213,9 @@ discard block |
||
208 | 213 | */ |
209 | 214 | public function detachPermission(Administrator $administrator, Role $role = null, Permission $model = null) |
210 | 215 | { |
211 | - if (static::isRoleLocked($role)) |
|
212 | - return false; |
|
216 | + if (static::isRoleLocked($role)) { |
|
217 | + return false; |
|
218 | + } |
|
213 | 219 | } |
214 | 220 | |
215 | 221 | /* ----------------------------------------------------------------- |