add price start & end doctor show
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Modules\Linksehat\Http\Controllers\Api;
|
|||||||
|
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
|
use App\Models\Practice;
|
||||||
use App\Models\Practitioner;
|
use App\Models\Practitioner;
|
||||||
use App\Models\PractitionerRole;
|
use App\Models\PractitionerRole;
|
||||||
use Illuminate\Contracts\Support\Renderable;
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
@@ -100,7 +101,7 @@ class DoctorController extends Controller
|
|||||||
$q->where('addresses.addressable_type', Organization::class);
|
$q->where('addresses.addressable_type', Organization::class);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'practitionerRoles.practices',
|
'practitionerRoles.practices.prices',
|
||||||
'practitionerRoles.availabilities',
|
'practitionerRoles.availabilities',
|
||||||
'person',
|
'person',
|
||||||
'metas',
|
'metas',
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Modules\Linksehat\Transformers;
|
namespace Modules\Linksehat\Transformers;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Modules\Linksehat\Transformers\Speciality\SpecialityResource;
|
use Modules\Linksehat\Transformers\Speciality\SpecialityResource;
|
||||||
|
|
||||||
@@ -40,6 +41,15 @@ class DoctorResource extends JsonResource
|
|||||||
$isWalkinAvailable = false;
|
$isWalkinAvailable = false;
|
||||||
$isInstantChatAvailable = false;
|
$isInstantChatAvailable = false;
|
||||||
|
|
||||||
|
// Get Price Range
|
||||||
|
foreach ($this->practitionerRoles as $practitionerRole) {
|
||||||
|
foreach ($practitionerRole->practices as $practice) {
|
||||||
|
foreach ($practice->prices as $price) {
|
||||||
|
$price_nets[] = $price->price_net;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->practitionerRoles as $practitionerRole) {
|
foreach ($this->practitionerRoles as $practitionerRole) {
|
||||||
$specialities[$practitionerRole->speciality_id]['id'] = $practitionerRole->speciality_id;
|
$specialities[$practitionerRole->speciality_id]['id'] = $practitionerRole->speciality_id;
|
||||||
$specialities[$practitionerRole->speciality_id]['code'] = $practitionerRole->speciality->code;
|
$specialities[$practitionerRole->speciality_id]['code'] = $practitionerRole->speciality->code;
|
||||||
@@ -111,9 +121,9 @@ class DoctorResource extends JsonResource
|
|||||||
'gender' => $this->person->gender ?? null,
|
'gender' => $this->person->gender ?? null,
|
||||||
'is_online' => false,
|
'is_online' => false,
|
||||||
'is_insurance_covered' => rand(0, 1) == 1,
|
'is_insurance_covered' => rand(0, 1) == 1,
|
||||||
'price_range' => 'Rp 100.000 - Rp 350.000',
|
'price_range' => Helper::currencyIdrFormat(min($price_nets)) . ' - ' . Helper::currencyIdrFormat(max($price_nets)),
|
||||||
'price_start' => '100000', // min
|
'price_start' => Helper::currencyIdrFormat(min($price_nets)), // min
|
||||||
'price_end' => '350000', // max
|
'price_end' => Helper::currencyIdrFormat(max($price_nets)), // max
|
||||||
'currency' => 'IDR',
|
'currency' => 'IDR',
|
||||||
'avatar_url' => asset('images/default-doctor-avatar.png'),
|
'avatar_url' => asset('images/default-doctor-avatar.png'),
|
||||||
'education' => $this->meta->education ?? '',
|
'education' => $this->meta->education ?? '',
|
||||||
|
|||||||
Reference in New Issue
Block a user