Update Only the “updated_at” Column On Your Model

LaravelPosted on

In some cases, it can be useful, to “touch” only the updated_at column on our model. By default, the model gets updated only, when we change something, so using the update() method would not update the timestamp if we don’t pass anything. To solve it we can use the touch() method:

// Retrieve the model
$model = Model::find($id);

// Update the "updated_at" column only

Need a web developer? Maybe we can help, get in touch!

Similar Posts

More content in Laravel category