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
Post a Comment