private function getAttachedMedia($model, $collection_name='')
{
$uploaded_media = [];
if (empty($collection_name)) {
$uploaded_files = $model->getMedia();
}
else {
$uploaded_files = $model->getMedia($collection_name);
}
if ($uploaded_files->count()) {
foreach ($uploaded_files as $file) {
$uploaded_media[] = [
'id' => $file->id,
'name' => $file->name,
'mime_type' => $file->mime_type,
'url' => $file->getFullUrl(),
'storage_path' => $file->getUrl(),
'full_path' => $file->getPath(),
];
}
}
return $uploaded_media;
}