我想創建一個帶有兩個鏈接的下拉菜單。 「刪除」和「編輯」鏈接。laravel方法在href鏈接?
對於刪除功能,我創建了一個表單。
{!! Former::horizontal_open()->method('DELETE')->action(action("Test\\[email protected]", $comment->id)) !!}
{!! Former::danger_submit('Delete') !!}
{!! Former::close() !!}
表單工作,這意味着我的評論被刪除,如果我按下按鈕。
不,我決定刪除刪除按鈕,並使用刪除鏈接做下拉菜單。所以我需要在我的下拉菜單中獲取此表單的邏輯。
但我還沒有在下拉列表中得到了這個..光「刪除」按鈕的下拉的這一部分:
<li><a href="#">
Delete
</a></li>
但我不能只是把我的控制器功能在「HREF鏈接「,導致沒有'刪除'方法,它不會工作。我希望你們都明白我想說什麼......我的英語不是最好的。
有人可以幫助我嗎?
感謝您的幫助!
我試圖像在此之前,但這沒有工作之一:
<li>
<a>
{!! Former::horizontal_open()->method('DELETE')->action(action("Test\\[email protected]", $comment->id)) !!}
Delete
{!! Former::close() !!}
</a>
</li>
我嘗試直接鏈接到路線:
<li><a href="{{ route('destroy', $comment->id) }}">Delete</a></li>
和我的路線是這樣的:
Route::delete('/show/{id}', 'Test\\[email protected]')->name('destroythread');
但這並沒有爲我工作..
所有/顯示/路線:
Route::get('/show/{id}', 'Test\\[email protected]');
Route::put('/show/{id}/edit', ['as' => 'editing', 'uses' => 'Test\\[email protected]']);
Route::get('/show/{id}/edit', 'Test\\[email protected]')->name('edit');
Route::delete('/show/{id}', 'Test\\[email protected]')->name('destroy');
Route::delete('/show/{id}', 'Test\\[email protected]')->name('destroythread'); // this is the route we are talking about
你爲什麼不將其鏈接到使用'@的TestController的destroythread'路線? –
@JilsonThomas請看看我的更新:) – ItzMe488
您使用的是哪個版本的laravel? –