Laravel 提示Route [login] not defined.错误

laravel访问需要登陆的页面,如果当前未登陆,出现如下错误:

Route [login] not defined.

如何解决,只需要在路由中命名即可

增加login路由

在web.php中给你的Login登录路由设置login名字:

```

Route::group(['prefix' => 'admin'], function () {
Route::get('/login', '\App\Http\Controllers\Admin\LoginController@index')->name('login');
Route::post('/login', '\App\Http\Controllers\Admin\LoginController@login');
Route::get('/logout', '\App\Http\Controllers\Admin\LoginController@logout')->name('logout');
Route::group(['middleware' => 'auth:admin'], function () {
// 后台首页
Route::get('/home', '\App\Http\Controllers\Admin\HomeController@index');
});
});

```

    A+
发布日期:2022年10月09日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: