我在这里收到InvalidArgumentException Route [login] not defined错误:
C:\xampp\htdocs\shopping\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.php
/**
* Get the URL to a named route.
*
* @param string $name
* @param mixed $parameters
* @param bool $absolute
* @return string
*
* @throws \InvalidArgumentException
*/
public function route($name, $parameters = [], $absolute = true)
{
if (! is_null($route = $this->routes->getByName($name))) {
return $this->toRoute($route, $parameters, $absolute);
}
throw new InvalidArgumentException("Route [{$name}] not defined.");
}
/**
* Get the URL for a given route instance.
*
* @param \Illuminate\Routing\Route $route
* @param mixed $parameters
* @param bool $absolute
* @return string
*
* @throws \Illuminate\Routing\Exceptions\UrlGenerationException
这是我的路线:
Route::group(['middleware' => ['auth']],function(){
route::get('/admin/dashboard','AdminController@dashboard');
});
这是我的方法:
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/home');
}
else{
return redirect()->action('AdminController@login')->with('success','please login to access');
}
return $next($request);
}