Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

amitavroy/doctor-app

40 stars
2 code files
View amitavroy/doctor-app on GitHub

app/Services/AppointmentService.php

Open in GitHub
use App\Models\Appointment;
 
class AppointmentService
{
public function getAppointments($today = false, $confirmed = true)
{
return Appointment::query()
->with(['patient' => function ($query) {
$query->select([
'id',
'name',
'weight',
'phone_number',
'patient_id',
]);
}], ['location' => function ($query) {
$query->select([
'location.name',
]);
}])
->when($today, function ($query) {
$query->where('date', now()->format('Y-m-d'));
})
->when($confirmed === true, function ($query) {
$query->where('visited', 1)->where('time', '!=', null);
})
->when($confirmed === false, function ($query) {
$query->where('visited', 0);
})
->orderByDesc('date')
->orderByDesc('id')
->paginate(20);
}
}

app/Http/Controllers/DoctorController.php

Open in GitHub
use App\Services\AppointmentService;
use Inertia\Inertia;
 
class DoctorController extends Controller
{
public function index(AppointmentService $appointmentService)
{
$appointments = $appointmentService->getAppointments(true, true);
return Inertia::render('DoctorDashboard')
->with('appointments', $appointments);
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.