make:auth onコマンドを使用して簡単な認証ページを作成すると、ログオンして正常に登録できますが、私がクリックしようとするとlogout
最新のupadte laravel 5.2これは私のAuthController
次のとおりです。Laravel 5.2 logout()が動作しません
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Validator;
class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
protected $redirectTo = '/home';
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
protected function validator(array $data)
{
return Validator::make($data, [
//@formatter:off
'username' => 'required|max:255',
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
//@formatter:on
]);
}
public function getLogout()
{
auth()->logout();
return redirect()->route('/home');
}
protected function create(array $data)
{
return User::create([
//@formatter:off
'username' => $data['username'],
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
//@formatter:on
]);
}
}
私はこの問題を持っているより多くの話題を読みますが、解決策は、ルート上の
Route::get('auth/logout', 'Auth\[email protected]');
を追加すると私の問題を解決するか、constructor
にmiddleware
を使うことができませんでした:
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
レイアウトにログアウトする私のリンクは次のとおりです。
<li><a href="{{ url('/auth/logout') }}"><i class="fa fa-btn fa-sign-out"></i>Logout</a></li>
、私はこのエラーを取得:
NotFoundHttpException in compiled.php line 8912:
フルスタックエラー:
in compiled.php line 8912
at RouteCollection->match(object(Request)) in compiled.php line 8264
at Router->findRoute(object(Request)) in compiled.php line 8212
at Router->dispatchToRoute(object(Request)) in compiled.php line 8207
at Router->dispatch(object(Request)) in compiled.php line 2419
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3286
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9963
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9948
at Pipeline->then(object(Closure)) in compiled.php line 2366
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2350
at Kernel->handle(object(Request)) in index.php line 54
「ルート:: get( 'auth/logout'、 'Auth \ AuthController @ getLogout'); ' – felipsmartins
@felipsmartinsはい、動作しません。エラーが発生します –