RemoveKey.php 573 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php

namespace App\Http\Middleware;

use Closure;
use Cookie;

class RemoveKey
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        // Check if a wrong Key Cookie is set and if so remove it
20
        if(Cookie::has("key") && app('App\Models\Key')->getStatus() === null){
21
22
23
24
25
            return redirect(route("removeCookie", ["ir" => url()->full()]));
        }
        return $next($request);
    }
}