我想创建一个带有两个链接的下拉菜单。 “删除”和“编辑”链接。
对于删除功能,我创建了一个表单。
{!! Former::horizontal_open()->method('DELETE')->action(action("Test\\TestController@destroythread", $comment->id)) !!}
{!! Former::danger_submit('Delete') !!}
{!! Former::close() !!}
该表单有效,这意味着如果我按下按钮,我的评论将被删除。
不,我决定删除删除按钮并使用删除链接进行下拉菜单。所以我需要在下拉菜单中获取此表单的逻辑。
但我在下拉菜单中没有这个。光学“删除”按钮是下拉菜单的这一部分:
<li><a href="#">
Delete
</a></li>
但我不能只是将我的控制器功能放在“href-link”中,因为如果没有“DELETE”方法,它将无法工作。我希望你们都明白我想说的……无论如何,我的英语不是最好的。
有人可以帮我解决这个问题吗?
谢谢你的帮助!
我之前尝试过这样的操作,但这也不起作用:
<li>
<a>
{!! Former::horizontal_open()->method('DELETE')->action(action("Test\\TestController@destroythread", $comment->id)) !!}
Delete
{!! Former::close() !!}
</a>
</li>
我尝试直接链接到路线:
<li><a href="{{ route('destroy', $comment->id) }}">Delete</a></li>
我的路线如下所示:
Route::delete('/show/{id}', 'Test\\TestController@destroythread')->name('destroythread');
但这对我没用..
所有/显示/路线:
Route::get('/show/{id}', 'Test\\TestController@show');
Route::put('/show/{id}/edit', ['as' => 'editing', 'uses' => 'Test\\TestController@update']);
Route::get('/show/{id}/edit', 'Test\\TestController@edit')->name('edit');
Route::delete('/show/{id}', 'Test\\TestController@destroy')->name('destroy');
Route::delete('/show/{id}', 'Test\\TestController@destroythread')->name('destroythread'); // this is the route we are talking about