We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
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:
<?php
$someModel = new SomeModel();
// do something with your model
$someModel->save(['touch' => false]);
Of course setTouchedRelations
will work as well:
<?php
$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.