How do I retrieve media by uuid? #2411
Unanswered
michaeljcoyne
asked this question in
Q&A
Replies: 2 comments
-
I have actually done it with $modelClass->deleteMedia($id); |
Beta Was this translation helpful? Give feedback.
0 replies
-
I don't know if there is a built-in way to do this, but you could always loop over the media associated with your model: $targetUuid = '0638a4ae-8fc0-4b98-b95d-01689d1f95a4';
$modelMedia = $model->getMedia('collection');
foreach($modelMedia as $key => $value) {
if ($value->uuid == $targetUuid) {
$value->delete();
break;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have tried
$modelClass->getMedia('handouts', ['uuid' => 'myuuid']);
To get specific file using the filter. Doesn't work.
What is the correct way?
I cactially want to retrieve and delete this file.
Thanks
Michael
Beta Was this translation helpful? Give feedback.
All reactions