CheckBlockedUser   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 6
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure;
6
use Auth;
7
use Illuminate\Http\Request;
8
9
class CheckBlockedUser
10
{
11
    /**
12
     * Handle an incoming request.
13
     *
14
     * @param  \Illuminate\Http\Request  $request
15
     * @param  \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse)  $next
16
     * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
17
     */
18
    public function handle($request, Closure $next)
19
{
20
    if (Auth::check() && Auth::user()->block === "yes") {
0 ignored issues
show
Bug introduced by
Accessing block on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
21
        return redirect()->route('blocked');
22
    }
23
    if (env('MAINTENANCE_MODE') == 'true' && (Auth::check() && Auth::user()->role != 'admin')) {
0 ignored issues
show
Bug introduced by
Accessing role on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
24
        return redirect(url(''));
25
    }
26
27
    return $next($request);
28
}
29
}