找不到路由

编程入门 行业动态 更新时间:2024-10-27 03:40:58
找不到路由-logout(Route is not found -logout)

我试图点击退出按钮,但它返回一个错误:

NotFoundHttpException in RouteCollection.php line 161:

getLogout中没有getLogout ,它之前有效,不知道为什么现在不行。

AuthController:

<?php namespace App\Http\Controllers\Auth; use App\User; use Validator; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\ThrottlesLogins; use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; class AuthController extends Controller { /* |-------------------------------------------------------------------------- | Registration & Login Controller |-------------------------------------------------------------------------- | | This controller handles the registration of new users, as well as the | authentication of existing users. By default, this controller uses | a simple trait to add these behaviors. Why don't you explore it? | */ use AuthenticatesAndRegistersUsers, ThrottlesLogins; protected $redirectTo = "dashboard"; protected $loginPath = 'auth/login'; /** * Create a new authentication controller instance. * * @return void */ public function __construct() { $this->middleware('guest', ['except' => 'getLogout']); } /** * Get a validator for an incoming registration request. * * @param array $data * @return \Illuminate\Contracts\Validation\Validator */ protected function validator(array $data) { return Validator::make($data, [ 'name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'username' => 'required|max:20|unique:users', 'password' => 'required|confirmed|min:6', ]); } /** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'username' => $data['username'], 'password' => bcrypt($data['password']), ]); } }

routes.php文件:

Route::get('auth/logout', 'Auth\AuthController@getLogout');

视图:

<a href="auth/logout">Logout</a>

I am trying to click on logout button, but it returns an error:

NotFoundHttpException in RouteCollection.php line 161:

There's no getLogout in Authcontroller, and it worked before, not sure why now it isn't.

AuthController:

<?php namespace App\Http\Controllers\Auth; use App\User; use Validator; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\ThrottlesLogins; use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; class AuthController extends Controller { /* |-------------------------------------------------------------------------- | Registration & Login Controller |-------------------------------------------------------------------------- | | This controller handles the registration of new users, as well as the | authentication of existing users. By default, this controller uses | a simple trait to add these behaviors. Why don't you explore it? | */ use AuthenticatesAndRegistersUsers, ThrottlesLogins; protected $redirectTo = "dashboard"; protected $loginPath = 'auth/login'; /** * Create a new authentication controller instance. * * @return void */ public function __construct() { $this->middleware('guest', ['except' => 'getLogout']); } /** * Get a validator for an incoming registration request. * * @param array $data * @return \Illuminate\Contracts\Validation\Validator */ protected function validator(array $data) { return Validator::make($data, [ 'name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'username' => 'required|max:20|unique:users', 'password' => 'required|confirmed|min:6', ]); } /** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'username' => $data['username'], 'password' => bcrypt($data['password']), ]); } }

Routes.php:

Route::get('auth/logout', 'Auth\AuthController@getLogout');

view:

<a href="auth/logout">Logout</a>

最满意答案

尝试

<a href="/auth/logout">Logout</a>

或者给你的路线命名

Route::get('auth/logout', ['as' => 'logout', 'uses' => 'Auth\AuthController@getLogout');

并做

<a href="{{route('logout')}}">Logout</a>

Try

<a href="/auth/logout">Logout</a>

Or give your route a name

Route::get('auth/logout', ['as' => 'logout', 'uses' => 'Auth\AuthController@getLogout');

and do

<a href="{{route('logout')}}">Logout</a>

更多推荐

本文发布于:2023-08-02 23:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1382445.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   路由

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!