ContestAccount   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 4
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure, Auth, Redirect;
6
7
class ContestAccount
8
{
9
    /**
10
     * Handle an incoming request.
11
     *
12
     * @param  \Illuminate\Http\Request  $request
13
     * @param  \Closure  $next
14
     * @return mixed
15
     */
16
    public function handle($request, Closure $next)
17
    {
18
        if (!Auth::check()) {
19
            return $next($request);
20
        } elseif (is_null(Auth::user()->contest_account)) {
0 ignored issues
show
Bug introduced by
Accessing contest_account on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
21
            return $next($request);
22
        } elseif ($request->cid==Auth::user()->contest_account) {
23
            return $next($request);
24
        } else {
25
            return Redirect::route('contest.detail', ['cid' => Auth::user()->contest_account]);
26
        }
27
28
    }
29
}
30