api doctor detail

This commit is contained in:
Muhammad Fajar
2022-10-27 14:37:12 +07:00
parent 0ece467d21
commit 2f84f43ae5
11 changed files with 245 additions and 106 deletions

View File

@@ -17,7 +17,7 @@ class DoctorResource extends JsonResource
return [
'id' => $this->practitioner->person->id,
'name' => $this->practitioner->person->name,
'specialis' => $this->speciality->name,
'specialis' => "Spesialis " . $this->speciality->name,
'photos' => [
'title' => 'doctors-avatar-' . $this->id,
'url' => asset('images/default-doctor-avatar.png')

View File

@@ -15,10 +15,16 @@ class HospitalResource extends JsonResource
*/
public function toArray($request)
{
if (empty($this->distance)) {
$address = $this->currentAddress->text;
} else {
$address = $this->currentAddress;
}
return [
'id' => $this->id,
'name' => $this->name,
'address' => $this->currentAddress->text ?? null,
'address' => $address ?? null,
'distance' => $this->distance ? ($this->distance < 1 ? round($this->distance * 1000, 2) . " m" : round($this->distance, 2) . " km") : null,
'photos' => [
'title' => Str::slug($this->name),