@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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); |
@@ -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 |
@@ -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 | /* ----------------------------------------------------------------- |
@@ -109,7 +109,8 @@ |
||
109 | 109 | */ |
110 | 110 | public function detachRole(Administrator $administrator, Permission $permission = null, Role $role = null) |
111 | 111 | { |
112 | - if ( ! is_null($role)) |
|
113 | - return ! $role->isLocked(); |
|
112 | + if ( ! is_null($role)) { |
|
113 | + return ! $role->isLocked(); |
|
114 | + } |
|
114 | 115 | } |
115 | 116 | } |
@@ -205,8 +205,9 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function delete(Administrator $administrator, User $user = null) |
207 | 207 | { |
208 | - if ( ! is_null($user)) |
|
209 | - return $user->isDeletable(); |
|
208 | + if ( ! is_null($user)) { |
|
209 | + return $user->isDeletable(); |
|
210 | + } |
|
210 | 211 | } |
211 | 212 | |
212 | 213 | /** |
@@ -219,8 +220,9 @@ discard block |
||
219 | 220 | */ |
220 | 221 | public function forceDelete(Administrator $administrator, User $user = null) |
221 | 222 | { |
222 | - if ( ! is_null($user)) |
|
223 | - return $user->isDeletable(); |
|
223 | + if ( ! is_null($user)) { |
|
224 | + return $user->isDeletable(); |
|
225 | + } |
|
224 | 226 | } |
225 | 227 | |
226 | 228 | /** |