@@ -24,8 +24,9 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function handle($request, Closure $next) |
| 26 | 26 | { |
| 27 | - if ( ! $this->isAjaxRequest($request)) |
|
| 28 | - abort(400, 'Bad Request'); |
|
| 27 | + if ( ! $this->isAjaxRequest($request)) { |
|
| 28 | + abort(400, 'Bad Request'); |
|
| 29 | + } |
|
| 29 | 30 | |
| 30 | 31 | return $next($request); |
| 31 | 32 | } |
@@ -46,11 +46,13 @@ |
||
| 46 | 46 | protected function inExceptArray($request) |
| 47 | 47 | { |
| 48 | 48 | foreach ($this->exceptUris() as $except) { |
| 49 | - if ($except !== '/') |
|
| 50 | - $except = trim($except, '/'); |
|
| 49 | + if ($except !== '/') { |
|
| 50 | + $except = trim($except, '/'); |
|
| 51 | + } |
|
| 51 | 52 | |
| 52 | - if ($request->fullUrlIs($except) || $request->is($except)) |
|
| 53 | - return true; |
|
| 53 | + if ($request->fullUrlIs($except) || $request->is($except)) { |
|
| 54 | + return true; |
|
| 55 | + } |
|
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | return false; |
@@ -41,10 +41,12 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | protected function ensureUserCanAccessAdminPanel($user) |
| 43 | 43 | { |
| 44 | - if (is_null($user)) |
|
| 45 | - abort(404, 'Page not found'); |
|
| 44 | + if (is_null($user)) { |
|
| 45 | + abort(404, 'Page not found'); |
|
| 46 | + } |
|
| 46 | 47 | |
| 47 | - if ( ! $user->isAdmin() && ! $user->isModerator()) |
|
| 48 | - abort(404, 'Page not found'); |
|
| 48 | + if ( ! $user->isAdmin() && ! $user->isModerator()) { |
|
| 49 | + abort(404, 'Page not found'); |
|
| 50 | + } |
|
| 49 | 51 | } |
| 50 | 52 | } |
@@ -29,8 +29,9 @@ |
||
| 29 | 29 | |
| 30 | 30 | $metric = $manager->get($class); |
| 31 | 31 | |
| 32 | - if ($metric->authorizedToSee($request)) |
|
| 33 | - return response()->json($metric->resolve($request)->toArray()); |
|
| 32 | + if ($metric->authorizedToSee($request)) { |
|
| 33 | + return response()->json($metric->resolve($request)->toArray()); |
|
| 34 | + } |
|
| 34 | 35 | |
| 35 | 36 | return response()->json([ |
| 36 | 37 | 'message' => 'Access Not Allowed', |
@@ -170,8 +170,9 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function scopeFilterByAuthenticatedUser(Builder $query, User $user) |
| 172 | 172 | { |
| 173 | - if ($user->isSuperAdmin()) |
|
| 174 | - return $query; |
|
| 173 | + if ($user->isSuperAdmin()) { |
|
| 174 | + return $query; |
|
| 175 | + } |
|
| 175 | 176 | |
| 176 | 177 | return $query->where('key', '!=', static::ADMINISTRATOR); |
| 177 | 178 | } |
@@ -302,8 +303,9 @@ discard block |
||
| 302 | 303 | */ |
| 303 | 304 | public function attachUser($user, bool $reload = true) |
| 304 | 305 | { |
| 305 | - if ($this->hasUser($user)) |
|
| 306 | - return; |
|
| 306 | + if ($this->hasUser($user)) { |
|
| 307 | + return; |
|
| 308 | + } |
|
| 307 | 309 | |
| 308 | 310 | event(new AttachingUserToRole($this, $user)); |
| 309 | 311 | $this->users()->attach($user); |
@@ -343,8 +345,9 @@ discard block |
||
| 343 | 345 | */ |
| 344 | 346 | public function attachPermission($permission, bool $reload = true) |
| 345 | 347 | { |
| 346 | - if ($this->hasPermission($permission)) |
|
| 347 | - return; |
|
| 348 | + if ($this->hasPermission($permission)) { |
|
| 349 | + return; |
|
| 350 | + } |
|
| 348 | 351 | |
| 349 | 352 | event(new AttachingPermissionToRole($this, $permission)); |
| 350 | 353 | $this->permissions()->attach($permission); |
@@ -395,8 +398,9 @@ discard block |
||
| 395 | 398 | */ |
| 396 | 399 | public function can(string $ability): bool |
| 397 | 400 | { |
| 398 | - if ( ! $this->isActive()) |
|
| 399 | - return false; |
|
| 401 | + if ( ! $this->isActive()) { |
|
| 402 | + return false; |
|
| 403 | + } |
|
| 400 | 404 | |
| 401 | 405 | return $this->permissions->filter(function (Permission $permission) use ($ability) { |
| 402 | 406 | return $permission->hasAbility($ability); |
@@ -159,8 +159,9 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function attachPermission(&$permission, bool $reload = true) |
| 161 | 161 | { |
| 162 | - if ($this->hasPermission($permission)) |
|
| 163 | - return; |
|
| 162 | + if ($this->hasPermission($permission)) { |
|
| 163 | + return; |
|
| 164 | + } |
|
| 164 | 165 | |
| 165 | 166 | event(new AttachingPermissionToGroup($this, $permission)); |
| 166 | 167 | $permission = $this->permissions()->save($permission); |
@@ -181,8 +182,9 @@ discard block |
||
| 181 | 182 | { |
| 182 | 183 | $permission = $this->getPermissionById($id); |
| 183 | 184 | |
| 184 | - if ($permission !== null) |
|
| 185 | - $this->attachPermission($permission, $reload); |
|
| 185 | + if ($permission !== null) { |
|
| 186 | + $this->attachPermission($permission, $reload); |
|
| 187 | + } |
|
| 186 | 188 | |
| 187 | 189 | return $permission; |
| 188 | 190 | } |
@@ -214,8 +216,9 @@ discard block |
||
| 214 | 216 | */ |
| 215 | 217 | public function detachPermission(&$permission, bool $reload = true) |
| 216 | 218 | { |
| 217 | - if ( ! $this->hasPermission($permission)) |
|
| 218 | - return; |
|
| 219 | + if ( ! $this->hasPermission($permission)) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 219 | 222 | |
| 220 | 223 | $permission = $this->getPermissionFromGroup($permission); |
| 221 | 224 | |
@@ -236,8 +239,9 @@ discard block |
||
| 236 | 239 | */ |
| 237 | 240 | public function detachPermissionById($id, bool $reload = true) |
| 238 | 241 | { |
| 239 | - if ( ! is_null($permission = $this->getPermissionById($id))) |
|
| 240 | - $this->detachPermission($permission, $reload); |
|
| 242 | + if ( ! is_null($permission = $this->getPermissionById($id))) { |
|
| 243 | + $this->detachPermission($permission, $reload); |
|
| 244 | + } |
|
| 241 | 245 | |
| 242 | 246 | return $permission; |
| 243 | 247 | } |
@@ -285,8 +289,9 @@ discard block |
||
| 285 | 289 | */ |
| 286 | 290 | public function hasPermission($id) |
| 287 | 291 | { |
| 288 | - if ($id instanceof Model) |
|
| 289 | - $id = $id->getKey(); |
|
| 292 | + if ($id instanceof Model) { |
|
| 293 | + $id = $id->getKey(); |
|
| 294 | + } |
|
| 290 | 295 | |
| 291 | 296 | return $this->getPermissionFromGroup($id) !== null; |
| 292 | 297 | } |
@@ -305,8 +310,9 @@ discard block |
||
| 305 | 310 | */ |
| 306 | 311 | private function getPermissionFromGroup($id) |
| 307 | 312 | { |
| 308 | - if ($id instanceof Model) |
|
| 309 | - $id = $id->getKey(); |
|
| 313 | + if ($id instanceof Model) { |
|
| 314 | + $id = $id->getKey(); |
|
| 315 | + } |
|
| 310 | 316 | |
| 311 | 317 | $this->loadPermissions(); |
| 312 | 318 | |
@@ -187,8 +187,9 @@ |
||
| 187 | 187 | */ |
| 188 | 188 | public function scopeFilterByAuthenticatedUser(Builder $query, User $user) |
| 189 | 189 | { |
| 190 | - if ($user->isSuperAdmin()) |
|
| 191 | - return $query; |
|
| 190 | + if ($user->isSuperAdmin()) { |
|
| 191 | + return $query; |
|
| 192 | + } |
|
| 192 | 193 | |
| 193 | 194 | return $query->where('is_admin', '!=', true); |
| 194 | 195 | } |
@@ -148,8 +148,9 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function show(AuthenticatedUser $user, User $model = null) |
| 150 | 150 | { |
| 151 | - if ($model && $model->isSuperAdmin() && ! $user->isSuperAdmin()) |
|
| 152 | - return false; |
|
| 151 | + if ($model && $model->isSuperAdmin() && ! $user->isSuperAdmin()) { |
|
| 152 | + return false; |
|
| 153 | + } |
|
| 153 | 154 | } |
| 154 | 155 | |
| 155 | 156 | /** |
@@ -187,11 +188,13 @@ discard block |
||
| 187 | 188 | */ |
| 188 | 189 | public function activate(AuthenticatedUser $user, User $model = null) |
| 189 | 190 | { |
| 190 | - if ($user->is($model)) |
|
| 191 | - return false; |
|
| 191 | + if ($user->is($model)) { |
|
| 192 | + return false; |
|
| 193 | + } |
|
| 192 | 194 | |
| 193 | - if ( ! is_null($model) && $model->isSuperAdmin()) |
|
| 194 | - return false; |
|
| 195 | + if ( ! is_null($model) && $model->isSuperAdmin()) { |
|
| 196 | + return false; |
|
| 197 | + } |
|
| 195 | 198 | } |
| 196 | 199 | |
| 197 | 200 | /** |
@@ -204,11 +207,13 @@ discard block |
||
| 204 | 207 | */ |
| 205 | 208 | public function delete(AuthenticatedUser $user, User $model = null) |
| 206 | 209 | { |
| 207 | - if ($user->is($model)) |
|
| 208 | - return false; |
|
| 210 | + if ($user->is($model)) { |
|
| 211 | + return false; |
|
| 212 | + } |
|
| 209 | 213 | |
| 210 | - if ( ! is_null($model)) |
|
| 211 | - return $model->isDeletable(); |
|
| 214 | + if ( ! is_null($model)) { |
|
| 215 | + return $model->isDeletable(); |
|
| 216 | + } |
|
| 212 | 217 | } |
| 213 | 218 | |
| 214 | 219 | /** |
@@ -221,8 +226,9 @@ discard block |
||
| 221 | 226 | */ |
| 222 | 227 | public function forceDelete(AuthenticatedUser $user, User $model = null) |
| 223 | 228 | { |
| 224 | - if ( ! is_null($model)) |
|
| 225 | - return $model->isDeletable(); |
|
| 229 | + if ( ! is_null($model)) { |
|
| 230 | + return $model->isDeletable(); |
|
| 231 | + } |
|
| 226 | 232 | } |
| 227 | 233 | |
| 228 | 234 | /** |
@@ -235,8 +241,9 @@ discard block |
||
| 235 | 241 | */ |
| 236 | 242 | public function restore(AuthenticatedUser $user, User $model = null) |
| 237 | 243 | { |
| 238 | - if ( ! is_null($model)) |
|
| 239 | - return $model->trashed(); |
|
| 244 | + if ( ! is_null($model)) { |
|
| 245 | + return $model->trashed(); |
|
| 246 | + } |
|
| 240 | 247 | } |
| 241 | 248 | |
| 242 | 249 | /** |
@@ -249,8 +256,9 @@ discard block |
||
| 249 | 256 | */ |
| 250 | 257 | public function impersonate(AuthenticatedUser $user, User $model) |
| 251 | 258 | { |
| 252 | - if ($model->isAdmin()) |
|
| 253 | - return false; |
|
| 259 | + if ($model->isAdmin()) { |
|
| 260 | + return false; |
|
| 261 | + } |
|
| 254 | 262 | |
| 255 | 263 | return $user->isNot($model); |
| 256 | 264 | } |
@@ -126,8 +126,9 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function show(AuthenticatedUser $user, Role $model = null) |
| 128 | 128 | { |
| 129 | - if ($model && $model->key === Role::ADMINISTRATOR && ! $user->isSuperAdmin()) |
|
| 130 | - return false; |
|
| 129 | + if ($model && $model->key === Role::ADMINISTRATOR && ! $user->isSuperAdmin()) { |
|
| 130 | + return false; |
|
| 131 | + } |
|
| 131 | 132 | } |
| 132 | 133 | |
| 133 | 134 | /** |
@@ -165,8 +166,9 @@ discard block |
||
| 165 | 166 | */ |
| 166 | 167 | public function activate(AuthenticatedUser $user, Role $model = null) |
| 167 | 168 | { |
| 168 | - if (static::isRoleLocked($model)) |
|
| 169 | - return false; |
|
| 169 | + if (static::isRoleLocked($model)) { |
|
| 170 | + return false; |
|
| 171 | + } |
|
| 170 | 172 | } |
| 171 | 173 | |
| 172 | 174 | /** |
@@ -179,8 +181,9 @@ discard block |
||
| 179 | 181 | */ |
| 180 | 182 | public function delete(AuthenticatedUser $user, Role $model = null) |
| 181 | 183 | { |
| 182 | - if ( ! is_null($model)) |
|
| 183 | - return $model->isDeletable(); |
|
| 184 | + if ( ! is_null($model)) { |
|
| 185 | + return $model->isDeletable(); |
|
| 186 | + } |
|
| 184 | 187 | } |
| 185 | 188 | |
| 186 | 189 | /** |
@@ -194,11 +197,13 @@ discard block |
||
| 194 | 197 | */ |
| 195 | 198 | public function detachUser(AuthenticatedUser $user, Role $model = null, User $related = null) |
| 196 | 199 | { |
| 197 | - if (static::isRoleLocked($model)) |
|
| 198 | - return false; |
|
| 200 | + if (static::isRoleLocked($model)) { |
|
| 201 | + return false; |
|
| 202 | + } |
|
| 199 | 203 | |
| 200 | - if ( ! $user->isAdmin() && $related->isAdmin()) |
|
| 201 | - return false; |
|
| 204 | + if ( ! $user->isAdmin() && $related->isAdmin()) { |
|
| 205 | + return false; |
|
| 206 | + } |
|
| 202 | 207 | } |
| 203 | 208 | |
| 204 | 209 | /** |
@@ -212,8 +217,9 @@ discard block |
||
| 212 | 217 | */ |
| 213 | 218 | public function detachPermission(AuthenticatedUser $user, Role $model = null, Permission $related = null) |
| 214 | 219 | { |
| 215 | - if (static::isRoleLocked($model)) |
|
| 216 | - return false; |
|
| 220 | + if (static::isRoleLocked($model)) { |
|
| 221 | + return false; |
|
| 222 | + } |
|
| 217 | 223 | } |
| 218 | 224 | |
| 219 | 225 | /* ----------------------------------------------------------------- |