Setting the is_folder property to send to the json app

parent 5379d4ae
...@@ -25,8 +25,9 @@ class MediaTransformer extends Resource ...@@ -25,8 +25,9 @@ class MediaTransformer extends Resource
return [ return [
'id' => $this->id, 'id' => $this->id,
'filename' => $this->filename, 'filename' => $this->filename,
'path' => (string) $this->path, 'path' => $this->getPath(),
'is_image' => $this->isImage(), 'is_image' => $this->isImage(),
'is_folder' => $this->isFolder(),
'media_type' => $this->media_type, 'media_type' => $this->media_type,
'fa_icon' => FileHelper::getFaIcon($this->media_type), 'fa_icon' => FileHelper::getFaIcon($this->media_type),
'created_at' => $this->created_at, 'created_at' => $this->created_at,
...@@ -34,4 +35,13 @@ class MediaTransformer extends Resource ...@@ -34,4 +35,13 @@ class MediaTransformer extends Resource
'medium_thumb' => $this->imagy->getThumbnail($this->path,'mediumThumb'), 'medium_thumb' => $this->imagy->getThumbnail($this->path,'mediumThumb'),
]; ];
} }
private function getPath()
{
if ($this->is_folder) {
return $this->path->getRelativeUrl();
}
return (string) $this->path;
}
} }
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