Fix Doctor By Speciality
@@ -44,8 +44,15 @@ class DoctorController extends Controller
|
|||||||
$query->whereHas('practitioner.person', function ($person) use ($search) {
|
$query->whereHas('practitioner.person', function ($person) use ($search) {
|
||||||
$person->where('name', 'LIKE', '%' . $search . '%');
|
$person->where('name', 'LIKE', '%' . $search . '%');
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
->whereHas('speciality');
|
|
||||||
|
if ($request->has('speciality_id_in')) {
|
||||||
|
$speciality_ids = explode(',', $request->speciality_id_in);
|
||||||
|
$doctors->whereIn('speciality_id', $speciality_ids);
|
||||||
|
} else if ($request->has('speciality_id')) {
|
||||||
|
$doctors->where('speciality_id', $request->speciality_id);
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->has('hospital_id_in')) {
|
if ($request->has('hospital_id_in')) {
|
||||||
$hospital_ids = explode(',', $request->hospital_id_in);
|
$hospital_ids = explode(',', $request->hospital_id_in);
|
||||||
$doctors->whereIn('organization_id', $hospital_ids);
|
$doctors->whereIn('organization_id', $hospital_ids);
|
||||||
|
|||||||
@@ -18,43 +18,43 @@ class SpecialityController extends Controller
|
|||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
// 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(Response::HTTP_BAD_REQUEST, 'Missing Parameter' . $messageorganizationId . $messageSpecialityId);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $doctors = PractitionerRole::query()
|
||||||
|
// ->with(['practitioner.person', 'speciality', 'prices'])
|
||||||
|
// ->whereHas('prices', function ($query) {
|
||||||
|
// $query->where('priceable_type', Practice::class);
|
||||||
|
// })
|
||||||
|
// ->where('organization_id', $organizationId)
|
||||||
|
// ->where('speciality_id', $specialityId)
|
||||||
|
// ->get();
|
||||||
|
|
||||||
|
// abort_if(count($doctors) === 0, Response::HTTP_NOT_FOUND, 'Data Doctor tidak ditemukan');
|
||||||
|
|
||||||
|
// foreach ($doctors as $key => $doctor) {
|
||||||
|
// $specialisName = $doctor->speciality->name;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return Helper::responseJson([
|
||||||
|
// 'title' => 'Spesialis ' . $specialisName,
|
||||||
|
// 'doctors' => SpecialityResource::collection($doctors)
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function index()
|
||||||
{
|
{
|
||||||
$organizationId = $request->organization_id;
|
$specialities = Speciality::query()->get();
|
||||||
$specialityId = $request->speciality_id;
|
|
||||||
|
|
||||||
if (empty($organizationId) || empty($specialityId)) {
|
return Helper::responseJson(['specialities' => $specialities]);
|
||||||
$messageorganizationId = !empty($organizationId) ? ' ' : ' organization_id or ';
|
|
||||||
$messageSpecialityId = !empty($specialityId) ? ' ' : 'speciality_id';
|
|
||||||
|
|
||||||
abort(Response::HTTP_BAD_REQUEST, 'Missing Parameter' . $messageorganizationId . $messageSpecialityId);
|
|
||||||
}
|
|
||||||
|
|
||||||
$doctors = PractitionerRole::query()
|
|
||||||
->with(['practitioner.person', 'speciality', 'prices'])
|
|
||||||
->whereHas('prices', function ($query) {
|
|
||||||
$query->where('priceable_type', Practice::class);
|
|
||||||
})
|
|
||||||
->where('organization_id', $organizationId)
|
|
||||||
->where('speciality_id', $specialityId)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
abort_if(count($doctors) === 0, Response::HTTP_NOT_FOUND, 'Data Doctor tidak ditemukan');
|
|
||||||
|
|
||||||
foreach ($doctors as $key => $doctor) {
|
|
||||||
$specialisName = $doctor->speciality->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Helper::responseJson([
|
|
||||||
'title' => 'Spesialis ' . $specialisName,
|
|
||||||
'doctors' => SpecialityResource::collection($doctors)
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function listSpeciality()
|
|
||||||
{
|
|
||||||
$querySpecialities = Speciality::query()->get(['name']);
|
|
||||||
|
|
||||||
return Helper::responseJson(['specialities' => SpecialityResource::collection($querySpecialities)]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Traits\Blameable;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Speciality extends Model
|
class Speciality extends Model
|
||||||
{
|
{
|
||||||
@@ -20,4 +21,22 @@ class Speciality extends Model
|
|||||||
'code',
|
'code',
|
||||||
'name'
|
'name'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $appends = [
|
||||||
|
'image_url'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getImageUrlAttribute()
|
||||||
|
{
|
||||||
|
return asset('images/specialities/'.Str::slug($this->name, '-').'.png');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |