31 lines
880 B
PHP
31 lines
880 B
PHP
<?php
|
|
|
|
namespace Modules\Linksehat\Transformers\Hospital;
|
|
|
|
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,
|
|
'address' => $this->address ?? null,
|
|
'distance' => $this->distance ? ($this->distance < 1 ? round($this->distance * 1000, 2) . " m" : round($this->distance, 2) . " km") : null,
|
|
'city_name' => $this->city_name ?? null,
|
|
'phone' => $this->meta->phone,
|
|
'photos' => [
|
|
'title' => $this->name,
|
|
'photo_url' => url('images/default-hospital-image.png'),
|
|
]
|
|
];
|
|
}
|
|
}
|