I am trying to implement a basic middleware in Laravel 5.0 but somehow I donot understand that its using the same namespace for the Guard Contract as of my middleware. Below is the code and exception that I am looking at.
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
class LoginMiddleWare {
/**
* Gaurd Implementation
* @var Gaurd
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Gaurd $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(!$this->auth->check())
{
return redirect()->route('login');
}
return $next($request);
}
}
ReflectionException in compiled.php line 1050: Class App\Http\Middleware\Gaurd does not exist