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>

and that's my route :

Route::group(['middleware' => ['web']], function () {
    // your routes here
Route::controller("home" , "homeController");
Route::controller("slideshow" , "slideshowController");
Route::controller("products" , "productsController");
Route::controller("category" , "categoryController");
Route::controller("product_image" , "productImageController");
Route::controller("product_detail" , "productDetailController");
Route::controller("team" , "teamController");

    // Authentication routes...
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');

// Registration routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');

});



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1TkfMlr
via IFTTT

Aucun commentaire:

Enregistrer un commentaire