kuvia/app/Http/Resources/Gallery.php

37 lines
1.2 KiB
PHP
Raw Normal View History

2021-02-08 00:15:18 +00:00
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class Gallery extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
$data = [];
$data["id"] = $this->id;
$data["name"] = $this->name;
$data["created"] = $this->gallery_create_time;
$data["url"] = [
"name" => $this->url,
"url" => url("/".$this->getTenant()->url."/".$this->url)];
$data["mainImage"] = [
"id" => $this->main_image,
"url" => [
"small" => url("/".$this->getTenant()->url."/".$this->url."/".$this->main_image."/file?size=small"),
"medium" => url("/".$this->getTenant()->url."/".$this->url."/".$this->main_image."/file?size=medium"),
"big" => url("/".$this->getTenant()->url."/".$this->url."/".$this->main_image."/file?size=big")
]];
$data["description"] = $this->description;
$data["tags"] = json_decode($this->tags);
return $data;
#return parent::toArray($request);
}
}