api get person/doctor by speciality
This commit is contained in:
@@ -105,10 +105,9 @@ class DoctorController extends Controller
|
|||||||
$query->select(['availability_id', 'day']);
|
$query->select(['availability_id', 'day']);
|
||||||
}])->where('practitioner_role_id', $id)->get(['id', 'start_time']);
|
}])->where('practitioner_role_id', $id)->get(['id', 'start_time']);
|
||||||
|
|
||||||
return $queryDoctor->is_chat_available;
|
|
||||||
$doctor = DoctorResourceDetail::make($queryDoctor);
|
$doctor = DoctorResourceDetail::make($queryDoctor);
|
||||||
$doctor['day_available'] = Helper::dailyAvailabilities($queryAvailables);
|
$doctor['day_available'] = Helper::dailyAvailabilities($queryAvailables);
|
||||||
// return $doctor;
|
|
||||||
return response()->json(compact('doctor'));
|
return response()->json(compact('doctor'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
namespace Modules\Linksehat\Http\Controllers\Api;
|
namespace Modules\Linksehat\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\Practice;
|
||||||
use App\Models\PractitionerRole;
|
use App\Models\PractitionerRole;
|
||||||
|
use App\Models\Price;
|
||||||
use Illuminate\Contracts\Support\Renderable;
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Routing\Controller;
|
use Illuminate\Routing\Controller;
|
||||||
|
use Modules\Linksehat\Transformers\Speciality\SpecialityResource;
|
||||||
|
|
||||||
class SpecialityController extends Controller
|
class SpecialityController extends Controller
|
||||||
{
|
{
|
||||||
@@ -25,7 +28,22 @@ class SpecialityController extends Controller
|
|||||||
abort(400, 'missing parameter' . $messageorganizationId . $messageSpecialityId);
|
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)
|
||||||
|
]
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Linksehat\Transformers\Speciality;
|
||||||
|
|
||||||
|
use App\Models\Practice;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class SpecialityResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'doctors' => [
|
||||||
|
'name' => $this->practitioner->person->name,
|
||||||
|
'specialis' => 'Spesialis ' . $this->speciality->name,
|
||||||
|
'experience' => rand(5, 12),
|
||||||
|
'rating' => rand(20, 100),
|
||||||
|
'price' => '',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,25 +18,22 @@ class Practice extends Model
|
|||||||
'deleted_by'
|
'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()
|
public function getPriceAttribute()
|
||||||
{
|
{
|
||||||
return $this->prices->where('priceable_id', $this->id)->max('price_net');
|
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()
|
public function prices()
|
||||||
{
|
{
|
||||||
return $this->morphMany(Price::class, 'priceable');
|
return $this->morphMany(Price::class, 'priceable');
|
||||||
|
|||||||
Reference in New Issue
Block a user