Code Duplication    Length = 21-21 lines in 2 locations

app/Http/Middleware/AuthorizeAdministrator.php 1 location

@@ 8-28 (lines=21) @@
5
use Closure;
6
use Illuminate\Auth\Access\AuthorizationException;
7
8
class AuthorizeAdministrator
9
{
10
    /**
11
     * Handle an incoming request.
12
     *
13
     * @param \Illuminate\Http\Request $request
14
     * @param \Closure                 $next
15
     *
16
     * @throws \Illuminate\Auth\Access\AuthorizationException
17
     *
18
     * @return mixed
19
     */
20
    public function handle($request, Closure $next)
21
    {
22
        if (! auth()->check() || ! auth()->user()->isAdmin()) {
23
            throw new AuthorizationException('Unauthorized.');
24
        }
25
26
        return $next($request);
27
    }
28
}
29

app/Http/Middleware/AuthorizeStudent.php 1 location

@@ 8-28 (lines=21) @@
5
use Closure;
6
use Illuminate\Auth\Access\AuthorizationException;
7
8
class AuthorizeStudent
9
{
10
    /**
11
     * Handle an incoming request.
12
     *
13
     * @param \Illuminate\Http\Request $request
14
     * @param \Closure                 $next
15
     *
16
     * @throws \Illuminate\Auth\Access\AuthorizationException
17
     *
18
     * @return mixed
19
     */
20
    public function handle($request, Closure $next)
21
    {
22
        if (! auth()->check() || ! auth()->user()->isStudent()) {
23
            throw new AuthorizationException('Unauthorized.');
24
        }
25
26
        return $next($request);
27
    }
28
}
29