php - Laravel-5 using fill() to update database -


i'm trying use fill() update current row in database. however, seems creating new row instead of updating each time.

does know wrong?

here's code:

$reserve->where('cookie_id', 'idcode')->first(); $reserve->fill($request->all())->save();  return redirect::to('checkout'); 

judging code you've misunderstood how fetch instance out database. see http://laravel.com/docs/5.1/eloquent#retrieving-single-models

try following

$reserve = reserve::where('cookie_id', $id)->first();  $reserve->fill($request->input())->save();  return redirect()->to('checkout'); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -