Administrator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 16 4
1
<?php namespace App\Http\Middleware;
2
3
use Closure;
4
use Illuminate\Auth\Guard;
5
6
class Administrator {
7
8
    protected $auth;
9
10
    public function __construct(Guard $auth)
11
    {
12
        $this->auth = $auth;
13
    }
14
15
	public function handle($request, Closure $next)
16
	{
17
        if ($this->auth->guest() || session('role')!=='ADMN' )
18
        {
19
            if ($request->ajax())
20
            {
21
                return response('Unauthorized.', 401);
22
            }
23
            else
24
            {
25
                return redirect()->guest('/');
26
            }
27
        }
28
29
		return $next($request);
30
	}
31
32
}
33