我不斷收到以下錯誤:Laravel 5.2缺少所需參數[路線:showtopic] [URI:主題/ {ID} /主題/ {ID}]
Missing required parameters for [Route: showtopic] [URI: theme/{id}/topics/{id}].
這是我的網站.PHP的樣子:在web.php
有關的一切話題
Route::get('/theme/{id}/topics/{id}', '[email protected]')->name('showtopic');
Route::get('/theme/{id}/topics/{id}/edit', '[email protected]')->name('edittopic');
Route::patch('/theme/{id}/topics/{id}/edit', '[email protected]')->name('updatetopic');
Route::get('/theme/{id}/topics/create', '[email protected]')->name('createtopic');
Route::post('/theme/{id}/topics/create', '[email protected]')->name('savetopic');
Route::delete('/theme/{id}/topics/{id}/delete', '[email protected]')->name('deletetopic');
一切方面ing主題web.php
Route::get('/theme/{id}/topics', '[email protected]')->name('showtheme');
Route::get('/theme/{id}/edit', '[email protected]')->name('edittheme');
Route::patch('/theme/{id}/edit', '[email protected]')->name('updatetheme');
Route::get('/theme/create', '[email protected]')->name('createtheme');
Route::post('/theme/create', '[email protected]')->name('savetheme');
Route::delete('/theme/{id}/delete', '[email protected]')->name('deletetheme');
我把這個問題的每一個路線關於這個問題。所以,當我點擊我的觀點鏈接:
<a href="{{ route('showtopic', ['id' => $topic->id]) }}"
我不斷收到我在這個問題 的開頭顯示的錯誤,我希望我做了這個夠清楚了你明白。如果我錯過了這個問題需要的信息,請通知我。在此先感謝
Theme.blade.php
<div class="col s12">
<div class="card">
<div class="card-content"><span class="card-title"> - Topics</span>
<div class="collection">
@foreach($topics as $topic)
<a href="{{ route('showtopic', ['theme_id' => $theme->id, 'topic_id' => $topic->id]) }}" class="collection-item avatar collection-link"><img src="/uploads/avatars/{{ $topic->user->avatar }}" alt="" class="circle">
<div class="row">
<div class="col s6">
<div class="row last-row">
<div class="col s12"><span class="title">Theme - {{ $topic->topic_title }}</span>
<p>{!! str_limit($topic->topic_text, $limit = 125, $end = '...') !!}</p>
</div>
</div>
<div class="row last-row">
<div class="col s12 post-timestamp">Posted by: {{ $topic->user->username }} op: {{ $topic->created_at }}</div>
</div>
</div>
<div class="col s2">
<h6 class="title center-align">Replies</h6>
<p class="center replies">{{ $topic->replies->count() }}</p>
</div>
<div class="col s2">
<h6 class="title center-align">Status</h6>
<div class="status-wrapper center-align"><span class="status-badge status-open">open</span></div>
</div>
<div class="col s2">
<h6 class="title center-align">Last reply</h6>
<p class="center-align"></p>
<p class="center-align">Tijd</p>
</div>
</div>
</a>
@endforeach
</div>
</div>
我認爲你的答案有效,但是它給我顯示了一個錯誤, 'Undefined variable:theme'因爲$主題沒有在這個刀片模板中定義。我該如何解決這個問題?我用theme.blade.php –
@ feudelcosine148更新了我的問題,將它更改爲帶有主題ID的問題。如果你還沒有它,你應該得到它並傳遞到視圖。 –
你能告訴我一個例子嗎?我不太明白你的意思 –