2016-05-26 4 views
0

Я пытаюсь нажать на кнопку выхода из системы, но она возвращает ошибку:маршрут не найден -logout

NotFoundHttpException in RouteCollection.php line 161: 

Там нет в Authcontroller нет 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\[email protected]'); 

вид:

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

'getLogout()' находится в черте 'AuthenticatesUsers', который вытягивается в в черте' AuthenticatesAndRegistersUsers' https: // GitHub. com/laravel/framework/blob/5.2/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php # L18 – haakym

+0

Не могли бы вы вставить полную ошибку в свой вопрос, пожалуйста. Является ли маршрут, на который он не может ответить определенно «auth/logout»? – haakym

+0

@haakym да. положив его на внешнюю ссылку на вставку, не можете вставлять сюда: https://justpaste.it/uo39 – osherdo

ответ

1

Попробуйте

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

Или дайте свой маршрут имя

Route::get('auth/logout', ['as' => 'logout', 'uses' => 'Auth\[email protected]'); 

и сделать

<a href="{{route('logout')}}">Logout</a> 
Смежные вопросы