api search hospital

This commit is contained in:
Muhammad Fajar
2022-11-03 05:11:57 +07:00
parent ba0023544f
commit d3edc6cb67
9 changed files with 130 additions and 135 deletions

View File

@@ -1,29 +0,0 @@
<?php
namespace Modules\Linksehat\Transformers\Dashboard;
use Illuminate\Http\Resources\Json\JsonResource;
use Str;
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->currentAddress ?? '',
'distance' => $this->distance ? ($this->distance < 1 ? round($this->distance * 1000, 2) . " m" : round($this->distance, 2) . " km") : null,
'photos' => [
'title' => Str::slug($this->name),
'url' => asset('images/default-hospital-image.png'),
]
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace Modules\Linksehat\Transformers;
namespace Modules\Linksehat\Transformers\Hospital;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -17,21 +17,13 @@ class HospitalResource extends JsonResource
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,
'address' => $this->address ?? 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'),
]
'title' => $this->name,
'photo_url' => url('images/default-hospital-image.png'),
]
];
}