0
我在app\ExceptionsHandler.php
中有一些代碼檢查URL是否存在,如果不存在,那麼它會檢查數據庫是否是自定義URL,如果是的話就會返回一個視圖。我認爲這個問題是因爲它沒有通過網絡中間件傳遞,所以會話和身份驗證都沒有啓動,因爲Auth::id()
爲空,即使我100%登錄Laravel 5缺少頁面和authed用戶
是否有一個更容易如何做到這一點?
public function render($request, Exception $exception)
{
if($exception instanceof NotFoundHttpException)
{
if(\App\EventMeter::isURL()) {
$ec = new EventsController();
return $ec->eventMeter();
}
if(\App\Tournament::isTournamentURL()) {
$t = new TournamentController();
return $t->home();
}
if(BountyHunter::isURL())
{
$bhc = new BountyHunterController();
return $bhc->home();
}
return response()->view('errors.missing',array(), 404);
}
return parent::render($request, $exception);
}
我想因爲你實例化了控制器!只是重定向當前請求,像這樣'return redirect() - > route('route.name');' – Maraboc
這並不能解決問題,因爲URL總是動態的。如果我要讓路由成爲一個靜態的URL,那麼這將工作正常,但URL永遠不會保持不變 – Ben
命中此方法'$ ec-> eventMeter()'的URL會改變? – Maraboc