kuvia/app/Http/Resources/Gallery.php

42 lines
1.3 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 = [];
2021-02-08 10:00:42 +00:00
#$data["id"] = $this->id;
2021-02-08 00:15:18 +00:00
$data["name"] = $this->name;
$data["created"] = $this->gallery_create_time;
$data["url"] = [
"name" => $this->url,
2021-02-08 10:00:42 +00:00
"url" => url("/".$this->getTenant()->url."/".$this->url),
"json" => url("/".$this->getTenant()->url."/".$this->url.".json"),
];
2021-02-08 00:15:18 +00:00
$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;
2021-02-08 10:00:42 +00:00
$t = json_decode($this->tags);
foreach ($t as $i => $g) {
$t[$i] = trim($g);
}
$data["tags"] = $t;
2021-02-08 00:15:18 +00:00
return $data;
}
}