Merge remote-tracking branch 'origin/mhmfajar'
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
namespace Modules\Linksehat\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Linksehat\Transformers\Speciality\SpecialityResource;
|
||||
|
||||
class DoctorResource extends JsonResource
|
||||
{
|
||||
@@ -112,8 +112,8 @@ class DoctorResource extends JsonResource
|
||||
'is_online' => false,
|
||||
'is_insurance_covered' => rand(0, 1) == 1,
|
||||
'price_range' => 'Rp 100.000 - Rp 350.000',
|
||||
'price_start' => '100000',
|
||||
'price_end' => '350000',
|
||||
'price_start' => '100000', // min
|
||||
'price_end' => '350000', // max
|
||||
'currency' => 'IDR',
|
||||
'avatar_url' => asset('images/default-doctor-avatar.png'),
|
||||
'education' => $this->meta->education ?? '',
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Modules\Linksehat\Transformers\Hospital;
|
||||
|
||||
use App\Models\PractitionerRole;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Modules\Linksehat\Transformers\Speciality\SpecialityForHospitalDetailResource;
|
||||
|
||||
class HospitalResource extends JsonResource
|
||||
{
|
||||
@@ -15,18 +15,10 @@ class HospitalResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$querySpecialitys = PractitionerRole::query()
|
||||
->with(['speciality'])
|
||||
->where('organization_id', $this->id)
|
||||
->whereNotNull('speciality_id')
|
||||
->orderBy('speciality_id')
|
||||
->groupBy('speciality_id')
|
||||
->get(['speciality_id']);
|
||||
|
||||
foreach ($querySpecialitys as $indexSpeciality => $speciality) {
|
||||
$specialitys[$indexSpeciality]['id'] = $speciality->speciality->id;
|
||||
$specialitys[$indexSpeciality]['name'] = $speciality->speciality->name;
|
||||
$specialitys[$indexSpeciality]['avatar'] = asset('images/default-specialisasi-image.png');
|
||||
if ($this->specialities) {
|
||||
$specialities = SpecialityForHospitalDetailResource::collection($this->specialities);
|
||||
} else {
|
||||
$specialities = [];
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -45,7 +37,10 @@ class HospitalResource extends JsonResource
|
||||
'photos' => [
|
||||
'title' => $this->name,
|
||||
'photo_url' => url('images/default-hospital-image.png'),
|
||||
]
|
||||
],
|
||||
$this->mergeWhen($this->specialities, [
|
||||
'specialities' => $specialities
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Transformers\Hospital;
|
||||
|
||||
use App\Models\PractitionerRole;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Str;
|
||||
|
||||
class HospitalResourceDetail extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$querySpecialitys = PractitionerRole::query()
|
||||
->with(['speciality'])
|
||||
->where('organization_id', $this->id)
|
||||
->whereNotNull('speciality_id')
|
||||
->orderBy('speciality_id')
|
||||
->groupBy('speciality_id')
|
||||
->get(['speciality_id']);
|
||||
|
||||
foreach ($querySpecialitys as $indexSpeciality => $speciality) {
|
||||
$specialitys[$indexSpeciality]['id'] = $speciality->speciality->id;
|
||||
$specialitys[$indexSpeciality]['name'] = $speciality->speciality->name;
|
||||
$specialitys[$indexSpeciality]['avatar'] = asset('images/default-specialisasi-image.png');
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'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),
|
||||
'url' => asset('images/default-hospital-image.png'),
|
||||
],
|
||||
'specialitys' => $specialitys
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Transformers\Speciality;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SpecialityForHospitalDetailResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => 'Spesialis ' . $this->name,
|
||||
'avatar' => url('images/default-hospital-image.png'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -30,13 +30,13 @@ class SpecialityResource extends JsonResource
|
||||
}
|
||||
|
||||
return [
|
||||
$this->mergeWhen($this->practitioner && $prices, [
|
||||
$this->mergeWhen($this->practitioner && $this->prices, [
|
||||
'id' => isset($this->practitioner->person->id) ? $this->practitioner->person->id : $this->practitioner_id,
|
||||
'name' => isset($this->practitioner->person->name) ? $this->practitioner->person->name : $this->person_name,
|
||||
'specialis' => 'Spesialis ' . (isset($this->speciality->name) ? $this->speciality->name : $this->speciality_name),
|
||||
'experience' => rand(5, 12),
|
||||
'rating' => rand(20, 100),
|
||||
'price' => Helper::currencyIdrFormat($prices) ?? null,
|
||||
'price' => isset($prices) ? Helper::currencyIdrFormat($prices) : null,
|
||||
]),
|
||||
$this->mergeWhen($this->name, [
|
||||
'title' => 'Spesialis ' . $this->name,
|
||||
|
||||
Reference in New Issue
Block a user