When adding media, update updated_at of the main model #3886
Answered
by
freekmurze
deniskorbakov
asked this question in
Ideas
-
Hi, thanks for project When adding files to the model, updated_at is not reset. Of course, you can write this yourself, but I think it would be better to add it to the library itself. What do you think? An example where the model's date is not updated: public function save(Message $model, array $files, CollectionName $collectionName): void
{
foreach ($files as $file) {
try {
$model->addMedia($file)
->usingFileName($file->hashName())
->withCustomProperties(
[
'original_name' => $file->getClientOriginalName(),
'size' => $file->getSize(),
]
)
->toMediaCollection($collectionName->value);
} catch (Throwable $exception) {
logger()->error($exception->getMessage());
abort(ResponseCode::HTTP_BAD_REQUEST, $exception->getMessage());
}
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
freekmurze
Mar 12, 2026
Replies: 1 comment
-
|
This has been added in v12. The parent model's |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
deniskorbakov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This has been added in v12. The parent model's
updated_atis now automatically touched (usingtouchQuietly()) when media is saved or deleted.