dongmei3869 2017-02-28 14:07
浏览 27
已采纳

Laravel 5.2表单更新错误

Okay so guys i've a problem when working with laravel's update & i've spent 3 days and no one can solve my problem too so i decide to ask you all pro coder, please kindly help me

First, this is part of my View (editkeluhan.blade.php)

<form class="form-horizontal" role="form" method="POST" action="{{ url('/editkeluhanadmin/{$keluhan->id}') }}" enctype="multipart/form-data">
                    {{ csrf_field() }}

                    <div>
                        <input name="_method" type="hidden" value="PATCH">
                    </div>

Second, This is my Route

Route::get('editkeluhan/{id}','AdminController@editkeluhan');
Route::post('editkeluhanadmin/{id}', 'AdminController@updatekeluhanadmin');

public function editkeluhan($id){
    $halaman="tindaklayanan";
    $keluhan=keluhan::findOrFail($id);
    return view('layanankonsumen.editkeluhan',compact('keluhan','halaman'));
}


public function updatekeluhanadmin(Keluhan $keluhan, Request $r){
    $halaman = 'tindaklayanan';
    $keluhan->update($r->all());
    return redirect('/');

Third, this is AdminController

public function editkeluhan($id){
    $halaman="tindaklayanan";
    $keluhan=keluhan::findOrFail($id);
    return view('layanankonsumen.editkeluhan',compact('keluhan','halaman'));
}

public function updatekeluhanadmin(Keluhan $keluhan, Request $r){
    $halaman = 'tindaklayanan';
    $keluhan->update($r->all());
    return redirect('/');
}

This is ERROR, but when i change my Route into this

Route::resource('editkeluhanadmin', 'AdminController@updatekeluhanadmin');

Error is gone BUT Its not update in database

Please Please Help me

  • 写回答

2条回答 默认 最新

  • doukun0888 2017-03-01 08:11
    关注

    Visit https://laracasts.com/discuss/channels/laravel/update-form-data-laravel-52 to see my disscussion there & the answer if anyone need, good luck.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?