73 words, 1 min read
When you are using the touches
feature in Laravel, you sometimes want to save a model without updating the timestamps of its owners (e.g. when you are
running a migration script).
To save a model without touching pass false to save method:
$someModel = new SomeModel();
// do something with your model
$someModel->save(['touch' => false]);
Of course setTouchedRelations will work as well:
$someModel = new SomeModel();
// do what you need
$someModel->setTouchedRelations([]);
$someModel->save();
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.