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:07:32 +00:00
|
|
|
|
2021-02-08 10:00:42 +00:00
|
|
|
$t = json_decode($this->tags);
|
2021-02-08 10:03:14 +00:00
|
|
|
if(is_array($t)) {
|
|
|
|
foreach ($t as $i => $g) {
|
|
|
|
$t[$i] = trim($g);
|
|
|
|
}
|
|
|
|
$data["tags"] = $t;
|
|
|
|
} else {
|
|
|
|
$data["tags"] = null;
|
2021-02-08 10:00:42 +00:00
|
|
|
}
|
2021-02-08 10:03:14 +00:00
|
|
|
|
2021-02-08 00:15:18 +00:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
}
|