我工作的一個Laravel項目中,我有以下途徑填補:缺少必要的參數異常,而參數是在URL
Route::group(['middleware' => ['web', 'auth'], 'prefix' => 'deliver'], function() {
Route::get("{pitch}/play", "[email protected]")->name("deliver.play");
Route::get('/', '[email protected]')->name('deliver');
});
命名deliver.play
路線被稱爲像這樣:
<a href="{{ route("deliver.play", $pitch) }}">
<span class="glyphicon glyphicon-picture" data-toggle="tooltip" data-placement="top" title="Go to Playmode"></span>
</a>
正如你所看到的,我通過$間距參數的路線,但是在執行時出現以下錯誤彈出:
ErrorException in UrlGenerationException.php line 17:
Missing required parameters for [Route: deliver.play] [URI: deliver/{pitch}/play].
這通常意味着{pitch}
參數是不給然而,在瀏覽器的地址欄的參數是有,給我的
http://localhost:8000/deliver/empty-pitch-13/play
完整的URL,這樣怎麼可能爲Laravel到沒有看到傳遞給路由的參數?還是有什麼我失蹤?
謝謝。
編輯:
我忘了補充控制器的路線鏈接。那就是:
public function play(Pitch $pitch)
{
if ($pitch->hasPresentation()) {
$presentation = head($pitch->presentations);
return view("deliver.play.index", $presentation);
}
return redirect()->route('slides.create', $pitch);
}
你在做什麼看起來精美絕倫。如果您看到例外頁面,您是如何看到地址欄中存在參數的網址?你確定它不是另一行,在你的視圖或其他視圖中導致錯誤的地方? – Jonathon