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

RoleMiddlware::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 3
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