@@ -311,7 +311,7 @@ |
||
311 | 311 | $this->loadPermissions(); |
312 | 312 | |
313 | 313 | return $this->permissions |
314 | - ->filter(function (Permission $permission) use ($id) { |
|
314 | + ->filter(function(Permission $permission) use ($id) { |
|
315 | 315 | return $permission->getKey() == $id; |
316 | 316 | }) |
317 | 317 | ->first(); |
@@ -170,8 +170,9 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function attachPermission(&$permission, bool $reload = true) |
172 | 172 | { |
173 | - if ($this->hasPermission($permission)) |
|
174 | - return; |
|
173 | + if ($this->hasPermission($permission)) { |
|
174 | + return; |
|
175 | + } |
|
175 | 176 | |
176 | 177 | event(new AttachingPermission($this, $permission)); |
177 | 178 | $permission = $this->permissions()->save($permission); |
@@ -192,8 +193,9 @@ discard block |
||
192 | 193 | { |
193 | 194 | $permission = $this->getPermissionById($id); |
194 | 195 | |
195 | - if ($permission !== null) |
|
196 | - $this->attachPermission($permission, $reload); |
|
196 | + if ($permission !== null) { |
|
197 | + $this->attachPermission($permission, $reload); |
|
198 | + } |
|
197 | 199 | |
198 | 200 | return $permission; |
199 | 201 | } |
@@ -225,8 +227,9 @@ discard block |
||
225 | 227 | */ |
226 | 228 | public function detachPermission(&$permission, bool $reload = true) |
227 | 229 | { |
228 | - if ( ! $this->hasPermission($permission)) |
|
229 | - return; |
|
230 | + if ( ! $this->hasPermission($permission)) { |
|
231 | + return; |
|
232 | + } |
|
230 | 233 | |
231 | 234 | $permission = $this->getPermissionFromGroup($permission); |
232 | 235 | |
@@ -247,8 +250,9 @@ discard block |
||
247 | 250 | */ |
248 | 251 | public function detachPermissionById($id, bool $reload = true) |
249 | 252 | { |
250 | - if ( ! is_null($permission = $this->getPermissionById($id))) |
|
251 | - $this->detachPermission($permission, $reload); |
|
253 | + if ( ! is_null($permission = $this->getPermissionById($id))) { |
|
254 | + $this->detachPermission($permission, $reload); |
|
255 | + } |
|
252 | 256 | |
253 | 257 | return $permission; |
254 | 258 | } |
@@ -296,8 +300,9 @@ discard block |
||
296 | 300 | */ |
297 | 301 | public function hasPermission($id) |
298 | 302 | { |
299 | - if ($id instanceof Model) |
|
300 | - $id = $id->getKey(); |
|
303 | + if ($id instanceof Model) { |
|
304 | + $id = $id->getKey(); |
|
305 | + } |
|
301 | 306 | |
302 | 307 | return $this->getPermissionFromGroup($id) !== null; |
303 | 308 | } |
@@ -316,8 +321,9 @@ discard block |
||
316 | 321 | */ |
317 | 322 | private function getPermissionFromGroup($id) |
318 | 323 | { |
319 | - if ($id instanceof Model) |
|
320 | - $id = $id->getKey(); |
|
324 | + if ($id instanceof Model) { |
|
325 | + $id = $id->getKey(); |
|
326 | + } |
|
321 | 327 | |
322 | 328 | $this->loadPermissions(); |
323 | 329 |
@@ -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); |
@@ -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 | } |
@@ -151,8 +151,9 @@ |
||
151 | 151 | public function getValidRecoveryCode(string $code) |
152 | 152 | { |
153 | 153 | foreach ($this->decrypted_recovery_codes as $recoveryCode) { |
154 | - if (hash_equals($code, $recoveryCode)) |
|
155 | - return $recoveryCode; |
|
154 | + if (hash_equals($code, $recoveryCode)) { |
|
155 | + return $recoveryCode; |
|
156 | + } |
|
156 | 157 | } |
157 | 158 | |
158 | 159 | return null; |
@@ -43,7 +43,7 @@ |
||
43 | 43 | */ |
44 | 44 | protected function registerCustomSessionHandler(SessionManager $session): void |
45 | 45 | { |
46 | - $session->extend('arcanesoft', function (Container $app) { |
|
46 | + $session->extend('arcanesoft', function(Container $app) { |
|
47 | 47 | return new DatabaseSessionHandler($app->make(SessionsRepository::class), $app); |
48 | 48 | }); |
49 | 49 | } |
@@ -169,8 +169,9 @@ |
||
169 | 169 | { |
170 | 170 | $emails = (array) static::config('administrators.emails'); |
171 | 171 | |
172 | - if (empty($emails)) |
|
173 | - return false; |
|
172 | + if (empty($emails)) { |
|
173 | + return false; |
|
174 | + } |
|
174 | 175 | |
175 | 176 | return in_array($user->email, $emails); |
176 | 177 | } |
@@ -72,8 +72,9 @@ |
||
72 | 72 | */ |
73 | 73 | public function verified($date = null): self |
74 | 74 | { |
75 | - if (is_null($date)) |
|
76 | - $date = now(); |
|
75 | + if (is_null($date)) { |
|
76 | + $date = now(); |
|
77 | + } |
|
77 | 78 | |
78 | 79 | return $this->state([ |
79 | 80 | 'email_verified_at' => $date === false ? null : $date, |
@@ -25,7 +25,7 @@ |
||
25 | 25 | */ |
26 | 26 | protected static function broker(): PasswordBroker |
27 | 27 | { |
28 | - return with(app('auth.password'), function (PasswordBrokerFactory $manager) { |
|
28 | + return with(app('auth.password'), function(PasswordBrokerFactory $manager) { |
|
29 | 29 | return $manager->broker(static::getBrokerDriver()); |
30 | 30 | }); |
31 | 31 | } |
@@ -41,8 +41,9 @@ discard block |
||
41 | 41 | { |
42 | 42 | $status = $this->broker()->sendResetLink($credentials); |
43 | 43 | |
44 | - if ($status === PasswordBroker::RESET_LINK_SENT) |
|
45 | - return $this->getSuccessResponse($request, $status); |
|
44 | + if ($status === PasswordBroker::RESET_LINK_SENT) { |
|
45 | + return $this->getSuccessResponse($request, $status); |
|
46 | + } |
|
46 | 47 | |
47 | 48 | return $this->getFailedResponse($request, $status); |
48 | 49 | } |
@@ -62,8 +63,9 @@ discard block |
||
62 | 63 | { |
63 | 64 | $status = trans($status); |
64 | 65 | |
65 | - if ($request->wantsJson()) |
|
66 | - return new JsonResponse(['message' => trans($status)], JsonResponse::HTTP_OK); |
|
66 | + if ($request->wantsJson()) { |
|
67 | + return new JsonResponse(['message' => trans($status)], JsonResponse::HTTP_OK); |
|
68 | + } |
|
67 | 69 | |
68 | 70 | return redirect() |
69 | 71 | ->back() |
@@ -82,10 +84,11 @@ discard block |
||
82 | 84 | { |
83 | 85 | $status = trans($status); |
84 | 86 | |
85 | - if ($request->wantsJson()) |
|
86 | - throw ValidationException::withMessages([ |
|
87 | + if ($request->wantsJson()) { |
|
88 | + throw ValidationException::withMessages([ |
|
87 | 89 | 'email' => $status, |
88 | 90 | ]); |
91 | + } |
|
89 | 92 | |
90 | 93 | return redirect() |
91 | 94 | ->back() |