fix code dashboard

This commit is contained in:
Muhammad Fajar
2022-10-31 07:09:24 +07:00
parent 9224bcef5b
commit 6d2404cca1
2 changed files with 36 additions and 26 deletions

View File

@@ -15,16 +15,10 @@ 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' => $address ?? null,
'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),