diff --git a/Modules/Linksehat/Http/Controllers/Api/DoctorController.php b/Modules/Linksehat/Http/Controllers/Api/DoctorController.php index eefa6ed5..687b0c50 100644 --- a/Modules/Linksehat/Http/Controllers/Api/DoctorController.php +++ b/Modules/Linksehat/Http/Controllers/Api/DoctorController.php @@ -105,10 +105,9 @@ class DoctorController extends Controller $query->select(['availability_id', 'day']); }])->where('practitioner_role_id', $id)->get(['id', 'start_time']); - return $queryDoctor->is_chat_available; $doctor = DoctorResourceDetail::make($queryDoctor); $doctor['day_available'] = Helper::dailyAvailabilities($queryAvailables); - // return $doctor; + return response()->json(compact('doctor')); } diff --git a/Modules/Linksehat/Http/Controllers/Api/SpecialityController.php b/Modules/Linksehat/Http/Controllers/Api/SpecialityController.php index 74df4b84..e31c3c1d 100644 --- a/Modules/Linksehat/Http/Controllers/Api/SpecialityController.php +++ b/Modules/Linksehat/Http/Controllers/Api/SpecialityController.php @@ -2,10 +2,13 @@ namespace Modules\Linksehat\Http\Controllers\Api; +use App\Models\Practice; use App\Models\PractitionerRole; +use App\Models\Price; use Illuminate\Contracts\Support\Renderable; use Illuminate\Http\Request; use Illuminate\Routing\Controller; +use Modules\Linksehat\Transformers\Speciality\SpecialityResource; class SpecialityController extends Controller { @@ -25,7 +28,22 @@ class SpecialityController extends Controller abort(400, 'missing parameter' . $messageorganizationId . $messageSpecialityId); } - return PractitionerRole::query()->with('practitioner')->where('organization_id', $organizationId)->where('speciality_id', $specialityId)->get(); + $doctors = PractitionerRole::query()->with(['practitioner.person', 'speciality'])->where('organization_id', $organizationId)->where('speciality_id', $specialityId)->get(); + + foreach ($doctors as $key => $doctor) { + $specialisName = $doctor->speciality->name; + } + + // Price belum ke ambil + return response()->json([ + 'status' => true, + 'statusCode' => 200, + 'message' => 'Data Berhasil di ambil', + 'data' => [ + 'title' => 'Spesialis ' . $specialisName, + 'doctors' => SpecialityResource::collection($doctors) + ] + ]); } /** diff --git a/Modules/Linksehat/Transformers/Speciality/SpecialityResource.php b/Modules/Linksehat/Transformers/Speciality/SpecialityResource.php new file mode 100644 index 00000000..beddb480 --- /dev/null +++ b/Modules/Linksehat/Transformers/Speciality/SpecialityResource.php @@ -0,0 +1,28 @@ + [ + 'name' => $this->practitioner->person->name, + 'specialis' => 'Spesialis ' . $this->speciality->name, + 'experience' => rand(5, 12), + 'rating' => rand(20, 100), + 'price' => '', + ] + ]; + } +} diff --git a/app/Models/Practice.php b/app/Models/Practice.php index 0c2ca774..a349eefd 100644 --- a/app/Models/Practice.php +++ b/app/Models/Practice.php @@ -18,25 +18,22 @@ class Practice extends Model 'deleted_by' ]; - // public $appends = [ - // 'price' - // ]; - - // public function getPriceAttribute() - // { - // $orgPrice = []; - // foreach ($this->prices as $price) { - // $orgPrice[$this->service_code] = $price->price_net; - // } - - // return $orgPrice; - // } - public function getPriceAttribute() { return $this->prices->where('priceable_id', $this->id)->max('price_net'); } + public function getPricesGroupOneAttribute() + { + $orgPrices = []; + + foreach ($this->prices->where('price_group_id', 1) as $price) { + $orgPrices[$this->service_code] = $price->price_net; + } + + return $orgPrices; + } + public function prices() { return $this->morphMany(Price::class, 'priceable');