猿问

Symfony \ Component \ HttpKernel \ Exception

当我单击删除按钮时,它会显示该错误。我无法找出问题所在。


路由.php


 Route::post('api/email/create', ['as' => 'email.create', 'uses' => 'Havence\AutoMailController@create']);

    Route::get('automail/mail',['as'=>'email.mail','uses' => 'Havence\AutoMailController@mail']);

    Route::get('automail/index',['as'=>'email.index','uses' => 'Havence\AutoMailController@index']);

    Route::get('automail/edit/{id}',['as'=>'email.edit','uses' => 'Havence\AutoMailController@edit']);

    Route::post('automail/delete/{id}',['as'=>'email.delete','uses' => 'Havence\AutoMailController@destroy']);

删除按钮功能


  <form  data-toggle="tooltip" title="Delete Template" data-placement="top" action="{{ route('email.delete', $mailTemplate->id) }}" method="POST">

    {{csrf_field()}}

    <input name="_method" type="hidden" value="DELETE">

    <button  type="submit" class="imgb col-md-3 text-center p-2"><img src="https://img.icons8.com/nolan/40/delete-forever.png" ></button>

</form>

控制器


 public function destroy($id)

    {

        $mailTemplates = Ticket::find($id);

        $mailTemplates->delete();


        return redirect('/index')->with('success', 'Ticket has been deleted!!');


    }


胡说叔叔
浏览 93回答 1
1回答

幕布斯6054654

更改此因为您正在传递隐藏的_methodRoute::post('automail/delete/{id}',['as'=>'email.delete','uses'&nbsp;=>&nbsp;'Havence\AutoMailController@destroy']);到Route::delete('automail/delete/{id}',['as'=>'email.delete','uses'&nbsp;=>&nbsp;'Havence\AutoMailController@destroy']);
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答