39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\Linksehat\Transformers;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class HospitalResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'name' => $this->name,
|
|
'code' => $this->code,
|
|
'description' => $this->description,
|
|
'address' => $this->currentAddress->text ?? null,
|
|
'lat' => $this->currentAddress->lat ?? null,
|
|
'lng' => $this->currentAddress->lng ?? null,
|
|
'distance' => isset($this->distance_km) ? round($this->distance_km) . ' km' : null,
|
|
'city_name' => $this->currentAddress->city->name ?? null,
|
|
'rating' => rand(350, 500) / 100,
|
|
'phone' => $this->meta->phone,
|
|
'photo_url' => asset('images/default-hospital-image.png'),
|
|
'photos' => [
|
|
[
|
|
'title' => $this->name,
|
|
'photo_url' => asset('images/default-hospital-image.png'),
|
|
]
|
|
]
|
|
];
|
|
}
|
|
}
|