dongnigeng1295 2017-04-05 11:00
浏览 43
已采纳

RouteCollection.php第233行中的MethodNotAllowedHttpException我认为EveryThing是正确的

I am learning laravel and I have a problem when I call to delete method.

My Routes:

Route::get('/', function () {
    return view('inicio');
});

Route::resource('secciones', 'seccionesController');

My form:

{{ Form::open(['route' => ['secciones.destroy', $seccion->id], 'method' => 'DELETE']) }}

{{ Form::submit('Delete') }}

{{ Form::close() }}

The $seccion->id is correct, the secciones.destroy (in seccionesController there are a destroy method ) is correct. When I call delete laravel return me:

MethodNotAllowedHttpException in RouteCollection.php line 233:

Can anyone help me?

Thanks in advance..

  • 写回答

1条回答 默认 最新

  • drkj41932 2017-04-05 11:09
    关注

    HTML Forms don't support DELETE method. But you can use {{ method_field('DELETE') }}

    Also, you forgot to add the {{ csrf_field() }} (token field) in the form.

    It will be:

    {{ Form::open(['route' => ['secciones.destroy', $seccion->id], 'method' => 'DELETE']) }}
    
    {{ method_field('DELETE') }}
    {{ csrf_field() }}
    
    {{ Form::submit('Delete') }}
    
    {{ Form::close() }}

    Good luck! :)

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳