add api linksehat/dashboard

This commit is contained in:
Muhammad Fajar
2022-10-25 18:13:02 +07:00
parent b0d74c222e
commit d0ce5772c2
6 changed files with 143 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
<?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 ?? null,
'distance' => $this->distance < 1 ? round($this->distance * 1000, 2) . " m" : round($this->distance, 2) . " km",
'photos' => [
'title' => Str::slug($this->name),
'url' => asset('images/default-doctor-avatar.png')
]
];
}
}