Add API
This commit is contained in:
19
Modules/Linksehat/Transformers/DoctorResource.php
Normal file
19
Modules/Linksehat/Transformers/DoctorResource.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DoctorResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return parent::toArray($request);
|
||||
}
|
||||
}
|
||||
37
Modules/Linksehat/Transformers/HospitalResource.php
Normal file
37
Modules/Linksehat/Transformers/HospitalResource.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Transformers;
|
||||
|
||||
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,
|
||||
'code' => $this->code,
|
||||
'description' => $this->description,
|
||||
'address' => $this->currentAddress->text ?? null,
|
||||
'lat' => $this->currentAddress->lat ?? null,
|
||||
'lng' => $this->currentAddress->lng ?? null,
|
||||
'distance' => '200 m',
|
||||
'city_name' => 'Kota Tangerang',
|
||||
'phone' => $this->meta->phone,
|
||||
'photo_url' => asset('images/default-hospital-image.png'),
|
||||
'photos' => [
|
||||
[
|
||||
'title' => $this->name,
|
||||
'photo_url' => asset('images/default-hospital-image.png'),
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PractitionerRoleToDoctorDetailResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'full_name' => $this->practitioner->person->full_name ?? null,
|
||||
'name_prefix' => $this->practitioner->person->name_prefix ?? null,
|
||||
'name' => $this->practitioner->person->name ?? null,
|
||||
'name_suffix' => $this->practitioner->person->name_suffix ?? null,
|
||||
'gender' => $this->practitioner->person->gender ?? null,
|
||||
'speciality_name' => !empty($this->speciality->name ?? null) ? 'Spesialis '. $this->speciality->name : 'Spesialis Empty',
|
||||
'is_online' => false,
|
||||
'price_range' => 'Rp 100.000 - Rp 350.000',
|
||||
'price_start' => '100000',
|
||||
'price_end' => '350000',
|
||||
'avatar_url' => asset('images/default-doctor-avatar.png'),
|
||||
'education' => $this->meta->education ?? '',
|
||||
'medical_treatment' => $this->meta->medical_treatment ?? '',
|
||||
'award' => $this->meta->award ?? '',
|
||||
'work_experience' => $this->meta->work_experience ?? '',
|
||||
'keilmuan' => $this->meta->keilmuan ?? '',
|
||||
'description' => $this->meta->description ?? ''
|
||||
];
|
||||
|
||||
return parent::toArray($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PractitionerRoleToDoctorResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'full_name' => $this->practitioner->person->full_name,
|
||||
'name_prefix' => $this->practitioner->person->name_prefix,
|
||||
'name' => $this->practitioner->person->name,
|
||||
'name_suffix' => $this->practitioner->person->name_suffix,
|
||||
'gender' => $this->practitioner->person->gender,
|
||||
'speciality_name' => !empty($this->speciality->name ?? null) ? 'Spesialis '. $this->speciality->name : 'Spesialis Empty',
|
||||
'is_online' => false,
|
||||
'price_range' => 'Rp 100.000 - Rp 350.000',
|
||||
'price_start' => '100000',
|
||||
'price_end' => '350000',
|
||||
'avatar_url' => asset('images/default-doctor-avatar.png'),
|
||||
];
|
||||
return parent::toArray($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user