Completed
Push — master ( 2deac4...4336a8 )
by Adam
07:24
created

Admin::handle()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 2
nop 2
dl 0
loc 7
ccs 0
cts 4
cp 0
crap 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Support\Facades\Auth;
7
8
class Admin
9
{
10
    /**
11
     * Handle an incoming request.
12
     *
13
     * @param \Illuminate\Http\Request $request
14
     * @param \Closure                 $next
15
     *
16
     * @return mixed
17
     */
18
    public function handle($request, Closure $next)
19
    {
20
        if (Auth::check() && Auth::user()->isAdmin()) {
0 ignored issues
show
Bug introduced by
The method isAdmin() does not exist on Illuminate\Contracts\Auth\Authenticatable. It seems like you code against a sub-type of Illuminate\Contracts\Auth\Authenticatable such as Illuminate\Foundation\Auth\User. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        if (Auth::check() && Auth::user()->/** @scrutinizer ignore-call */ isAdmin()) {
Loading history...
21
            return $next($request);
22
        }
23
24
        return redirect('home');
25
    }
26
}
27