Passed
Push — master ( 4a884d...c9d1fc )
by Jeff
12:14
created

RedirectIfNotEmployee   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 18
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 2
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure;
6
7
class RedirectIfNotEmployee
8
{
9
    /**
10
     * Handle an incoming request.
11
     *
12
     * @param  \Illuminate\Http\Request $request
13
     * @param  \Closure $next
14
     * @param string $guard
15
     * @return mixed
16
     */
17
    public function handle($request, Closure $next, $guard = 'employee')
18
    {
19
        if (!auth()->guard($guard)->check()) {
20
            $request->session()->flash('error', 'You must be an employee to see this page');
21
            return redirect(route('admin.login'));
22
        }
23
24
        return $next($request);
25
    }
26
}
27