Completed
Pull Request — master (#37)
by Tim
02:31
created

RoleMiddlware   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 1 Features 1
Metric Value
wmc 2
c 1
b 1
f 1
lcom 0
cbo 1
dl 0
loc 19
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 RoleMiddlware
8
{
9
    /**
10
     * Handle an incoming request.
11
     *
12
     * @param  \Illuminate\Http\Request $request
13
     * @param  \Closure $next
14
     * @param  string $role the acl role
15
     * @return mixed
16
     */
17
    public function handle($request, Closure $next, $role)
18
    {
19
        if (! auth()->user()->is($role)) {
0 ignored issues
show
Bug introduced by
The method user() does not seem to exist on object<Illuminate\Contracts\Auth\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
20
            return redirect()->back(302);
21
        }
22
23
        return $next($request);
24
    }
25
}
26