Adding the delete url based of media type (file/folder)

parent 1c3a6932
......@@ -41,6 +41,9 @@ class MediaTransformer extends Resource
'folder_id' => $this->folder_id,
'small_thumb' => $this->imagy->getThumbnail($this->path, 'smallThumb'),
'medium_thumb' => $this->imagy->getThumbnail($this->path, 'mediumThumb'),
'urls' => [
'delete_url' => $this->getDeleteUrl(),
],
];
foreach ($this->thumbnailManager->all() as $thumbnail) {
......@@ -74,4 +77,13 @@ class MediaTransformer extends Resource
return (string) $this->path;
}
private function getDeleteUrl()
{
if ($this->isImage()) {
return route('api.media.media.destroy', $this->id);
}
return route('api.media.folders.destroy', $this->id);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment