gpt4 book ai didi

php - 路由 [登录名] 未定义

转载 作者:IT王子 更新时间:2023-10-29 00:56:27 27 4
gpt4 key购买 nike

今天第一次尝试使用 Laravel。当我尝试访问 localhost/project/public 时出现以下错误:

InvalidArgumentException
Route [login] not defined.

app/routes.php:

<?php

Route::get('/', 'HomeController@redirect');
Route::get('login', 'LoginController@show');
Route::post('login', 'LoginController@do');
Route::get('dashboard', 'DashboardController@show');

app/controllers/HomeController.php:

<?php

class HomeController extends Controller {

public function redirect()
{
if (Auth::check())
return Redirect::route('dashboard');

return Redirect::route('login');
}

}

app/controllers/LoginContoller.php:

<?php

class LoginController extends Controller {

public function show()
{
if (Auth::check())
return Redirect::route('dashboard');

return View::make('login');
}

public function do()
{
// do login
}

}

app/controllers/DashboardController.php:

<?php

class DashboardController extends Controller {

public function show()
{
if (Auth::guest())
return Redirect::route('login');

return View::make('dashboard');
}

}

为什么会出现这个错误?

最佳答案

尝试在请求的 header 中添加:Accept=application/json postman or insomnia add header

关于php - 路由 [登录名] 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29303783/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com