我試圖獲得用戶可以創建主題的視圖。我在我的項目中做了很多次,但從來沒有得到這個錯誤,因爲所有其他的工作都很好。Laravel沒有關於型號[App Topic]的查詢結果創建
我得到錯誤No query results for model [App\Topic] create
。這是代碼。
這是應該把用戶帶到視圖的鏈接。
<div class="col s12">
<div class="card">
<div class="card-content clearfix">
<a href="{{ route('createtopic', ['theme_id' => $theme->id]) }}" class="waves-effect waves-light btn blue-grey darken-4">New topic <i class="material-icons right">edit</i></a>
</div>
</div>
</div>
這些是在這個問題中使用的路線。
Route::get('/theme/{theme_id}/topics/create', '[email protected]')->name('createtopic');
Route::post('/theme/{theme_id}/topics/create', '[email protected]')->name('savetopic');
Controller方法創建。
dd('Hij is er ' . $id);
而存儲方法是空的,鏈接不顯示DumpDie方法,而是顯示我的錯誤。所以沒有必要發佈我試圖展示的視圖,因爲這不是問題所在。提前致謝!
檢查您是否在刀片文件中傳遞了正確的ID。在返回此刀片的方法中使用dd。 – Vikash
我沒有返回視圖,因爲那是dd的位置。問題不在於創建方法,而在其他地方。我不知道在哪裏,這是問題 –
這意味着在你的數據庫中沒有這個ID存在行 – Vikash