add hospital detail
This commit is contained in:
132
Modules/Linksehat/Http/Controllers/Api/PersonController.php
Normal file
132
Modules/Linksehat/Http/Controllers/Api/PersonController.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Linksehat\Http\Controllers\Api;
|
||||
|
||||
use App\Models\PractitionerRole;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Linksehat\Transformers\Speciality\SpecialityResource;
|
||||
|
||||
class PersonController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$organizationId = $request->organization_id;
|
||||
$specialityId = $request->speciality_id;
|
||||
|
||||
if (empty($organizationId) || empty($specialityId)) {
|
||||
$messageorganizationId = !empty($organizationId) ? ' ' : ' organization_id or ';
|
||||
$messageSpecialityId = !empty($specialityId) ? ' ' : 'speciality_id';
|
||||
|
||||
abort(400, 'missing parameter' . $messageorganizationId . $messageSpecialityId);
|
||||
}
|
||||
|
||||
$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)
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function searchSpecialityOrPerson(Request $request)
|
||||
{
|
||||
$doctors = PractitionerRole::query()
|
||||
->with(['practitioner.person', 'speciality'])
|
||||
->whereHas('practitioner.person', function ($query) use ($request) {
|
||||
$query->where('name', 'LIKE', "%{$request->value}%");
|
||||
})
|
||||
// ->whereHas('speciality', function ($query) use ($request) {
|
||||
// $query->where('name', 'LIKE', "%{$request->value}%");
|
||||
// })
|
||||
->get();
|
||||
|
||||
return $doctors;
|
||||
|
||||
// Price belum ke ambil
|
||||
// return response()->json([
|
||||
// 'status' => true,
|
||||
// 'statusCode' => 200,
|
||||
// 'message' => 'Data Berhasil di ambil',
|
||||
// 'data' => [
|
||||
// 'title' => 'Spesialis ' . $specialisName,
|
||||
// 'doctors' => SpecialityResource::collection($doctors)
|
||||
// ]
|
||||
// ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
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;
|
||||
@@ -25,14 +23,24 @@ class SpecialityController extends Controller
|
||||
$messageorganizationId = !empty($organizationId) ? ' ' : ' organization_id or ';
|
||||
$messageSpecialityId = !empty($specialityId) ? ' ' : 'speciality_id';
|
||||
|
||||
abort(400, 'missing parameter' . $messageorganizationId . $messageSpecialityId);
|
||||
abort(400, 'Missing Parameter' . $messageorganizationId . $messageSpecialityId);
|
||||
}
|
||||
|
||||
$doctors = PractitionerRole::query()->with(['practitioner.person', 'speciality'])->where('organization_id', $organizationId)->where('speciality_id', $specialityId)->get();
|
||||
$doctors = PractitionerRole::query()
|
||||
->with(['practitioner.person', 'speciality', 'prices'])
|
||||
->whereHas('prices', function ($query) {
|
||||
$query->where('priceable_type', 'App\Models\Practice');
|
||||
})
|
||||
->where('organization_id', $organizationId)
|
||||
->where('speciality_id', $specialityId)
|
||||
->get();
|
||||
|
||||
foreach ($doctors as $key => $doctor) {
|
||||
$specialisName = $doctor->speciality->name;
|
||||
}
|
||||
// return $doctors;
|
||||
return SpecialityResource::collection($doctors);
|
||||
return 'c';
|
||||
|
||||
// Price belum ke ambil
|
||||
return response()->json([
|
||||
@@ -46,6 +54,32 @@ class SpecialityController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function searchSpecialityOrPerson(Request $request)
|
||||
{
|
||||
$doctors = PractitionerRole::query()
|
||||
->with(['practitioner.person', 'speciality'])
|
||||
->whereHas('practitioner.person', function ($query) use ($request) {
|
||||
$query->where('name', 'LIKE', "%{$request->value}%");
|
||||
})
|
||||
// ->whereHas('speciality', function ($query) use ($request) {
|
||||
// $query->where('name', 'LIKE', "%{$request->value}%");
|
||||
// })
|
||||
->get();
|
||||
|
||||
return $doctors;
|
||||
|
||||
// Price belum ke ambil
|
||||
// return response()->json([
|
||||
// 'status' => true,
|
||||
// 'statusCode' => 200,
|
||||
// 'message' => 'Data Berhasil di ambil',
|
||||
// 'data' => [
|
||||
// 'title' => 'Spesialis ' . $specialisName,
|
||||
// 'doctors' => SpecialityResource::collection($doctors)
|
||||
// ]
|
||||
// ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
|
||||
@@ -17,7 +17,7 @@ class HospitalResourceDetail extends JsonResource
|
||||
public function toArray($request)
|
||||
{
|
||||
$querySpecialitys = PractitionerRole::query()
|
||||
->with('speciality')
|
||||
->with(['speciality'])
|
||||
->where('organization_id', $this->id)
|
||||
->whereNotNull('speciality_id')
|
||||
->orderBy('speciality_id')
|
||||
@@ -27,7 +27,7 @@ class HospitalResourceDetail extends JsonResource
|
||||
foreach ($querySpecialitys as $indexSpeciality => $speciality) {
|
||||
$specialitys[$indexSpeciality]['id'] = $speciality->speciality->id;
|
||||
$specialitys[$indexSpeciality]['name'] = $speciality->speciality->name;
|
||||
$specialitys[$indexSpeciality]['avatar'] = null;
|
||||
$specialitys[$indexSpeciality]['avatar'] = asset('images/default-specialisasi-image.png');
|
||||
}
|
||||
|
||||
if (empty($this->distance)) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Modules\Linksehat\Transformers\Speciality;
|
||||
|
||||
use App\Models\Practice;
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SpecialityResource extends JsonResource
|
||||
@@ -15,13 +15,26 @@ class SpecialityResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
foreach ($this->practices as $practice) {
|
||||
if ($practice->service_code === 'walkin') {
|
||||
$practices[] = $practice->id;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->prices as $price) {
|
||||
if (in_array($price->priceable_id, $practices)) {
|
||||
$prices = $price->price_net;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'doctors' => [
|
||||
'id' => $this->practitioner->person->id,
|
||||
'name' => $this->practitioner->person->name,
|
||||
'specialis' => 'Spesialis ' . $this->speciality->name,
|
||||
'experience' => rand(5, 12),
|
||||
'rating' => rand(20, 100),
|
||||
'price' => '',
|
||||
'price' => Helper::currencyIdrFormat($prices),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -64,8 +64,18 @@ class PractitionerRole extends Model
|
||||
return $this->hasMany(Practice::class, 'practitioner_role_id');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasManyThrough(Price::class, Practice::class, 'practitioner_role_id', 'id');
|
||||
}
|
||||
|
||||
public function availabilities()
|
||||
{
|
||||
return $this->hasMany(PractitionerRoleAvailability::class, 'practitioner_role_id');
|
||||
}
|
||||
|
||||
public function person()
|
||||
{
|
||||
return $this->hasOneThrough(Person::class, Practitioner::class, 'person_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user