duangutian1426 2017-03-04 10:28
浏览 93
已采纳

MethodNotAllowedHttpException laravel 5

Why am I getting this error?

Routes:

Route::group(['prefix'=>'admin','middleware'=>'auth'],function(){
    Route::get('/',['uses'=>'Admin\IndexController@index','as'=>'adminIndex']);
    Route::resource('/products','Admin\ProductController');
});

Form:

{!! Form::open(['url' => route('admin.products.edit',['products'=>$product->id]),'class'=>'form-horizontal','method'=>'POST']) !!}
                    {{ method_field('EDIT')}}
                    {!! Form::button('Edit', ['id'=>'submit','type'=>'submit']) !!}
                    {!! Form::close() !!}

Also, when I'm trying to get list of routes by typing php artisan route:list, I'm getting error:

[Symfony\Component\HttpKernel\Exception\HttpException]

What's the problem?

  • 写回答

3条回答 默认 最新

  • dpfw3607 2017-03-04 10:46
    关注

    I think your resource under admin prefix does not take the admin prefix. So you still have to use it without admin prefix. Besides, you are using 'url' instead of 'route'.

    {!! Form::open(['url' => '/admin/products/'.$product->id.'/edit'),'class'=>'form-horizontal','method'=>'POST']) !!}
    

    If you want to keep using route

    {!! Form::open(['route' => ['products.edit', 'products'=>$product->id], 'class'=>'form-horizontal','method'=>'POST']) !!}
    

    If you are tryint to update instead

    {!! Form::model($product, ['method' => 'PATCH', 'route' => ['products.update', $product->id], 'class' => 'form-horizontal' ]) !!}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置