Laravel Eloquent: Model Update an existing model


Example

$user = User::find(1);
$user->name = 'abc';
$user->save();

You can also update multiple attributes at once using update, which does not require using save afterwards:

$user = User::find(1);
$user->update(['name' => 'abc', 'location' => 'xyz']);

You can also update a model(s) without querying it beforehand:

User::where('id', '>', 2)->update(['location' => 'xyz']);

If you don't want to trigger a change to the updated_at timestamp on the model then you can pass the touch option:

$user = User::find(1);
$user->update(['name' => 'abc', 'location' => 'xyz'], ['touch' => false]);