model laravel update code example

Example 1: laravel delete where

DB::table('users')->where('id', $id)->delete();

Example 2: laravel update

$flight = App\Models\Flight::find(1);

$flight->name = 'New Flight Name';

$flight->save();

Example 3: eloquent firstOrCreate

firstOrCreate() will automatically create a new entry in the database if there is not match found. Otherwise it will give you the matched item.
firstOrNew() will give you a new model instance to work with if not match was found, but will only be saved to the database when you explicitly do so (calling save() on the model). Otherwise it will give you the matched item.

Example 4: laravel eloquent fill

$flight->fill(['name' => 'Flight 22']);