lundi 25 janvier 2016

how to update a record in database using laravel

i'm trying to make update to a record in my database . i tried to make it several times but it seem to be the url is the problem can anyone help that's my controller method :

public function postEditCategory($id,Request $request){
        $name=$request->input('name');
        DB::table('category')->where('id',$id)->update(['name'=>$name]);
        return redirect('category');

and that's is my view :

<form action="category/Edit-category/{{$cat->id}}" method="POST" enctype="multipart/form-code">
                        {!! csrf_field() !!}
                        <input type="hidden" name="_method" value="PATCH" />
                        <td><input type="text" class="form-control" name="name" value="{{$cat->name}}"></td>
                        <td><button class="btn btn-success" type="submit">Update Category</button></td>
                        </form>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire