api search hospital
This commit is contained in:
30
Modules/Linksehat/Transformers/Hospital/HospitalResource.php
Normal file
30
Modules/Linksehat/Transformers/Hospital/HospitalResource.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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' => isset($this->distance_km) ? round($this->distance_km) . ' km' : null,
|
||||
'city_name' => $this->currentAddress->city->name ?? null,
|
||||
'phone' => $this->meta->phone,
|
||||
'photos' => [
|
||||
'title' => $this->name,
|
||||
'photo_url' => url('images/default-hospital-image.png'),
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user