User Tools

Site Tools


Sidebar

Dan's Wiki

DokuWiki Instructions (local) DokuWiki Manual
Site Checker (Orphans Wanted)

Edit Sidebar

laravel:eloquent

This is an old revision of the document!


(Laravel) Eloquent Notes

Inserting New Row

To create a new record in the database, simply create a new model instance, set attributes on the model, then call the save method:

  $flight = new Flight;
  $flight->name = $request->name;
  $flight->save();

Update Row

he save method may also be used to update models that already exist in the database. To update a model, you should retrieve it, set any attributes you wish to update, and then call the save method. Again, the updated_at timestamp will automatically be updated, so there is no need to manually set its value:

  $flight = App\Flight::find(1);
  $flight->name = 'New Flight Name';
  $flight->save();
laravel/eloquent.1482369898.txt.gz · Last modified: 2016/12/22 01:24 by dwheele