37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Patient;
|
|
|
|
use App\Models\Appointment;
|
|
use App\Models\News;
|
|
use Livewire\Component;
|
|
|
|
class Dashboard extends Component
|
|
{
|
|
public function render()
|
|
{
|
|
$userId = auth()->id();
|
|
$today = date('Y-m-d');
|
|
|
|
return view('livewire.patient.dashboard', [
|
|
'currentAppointment' => Appointment::with(['serviceCategory', 'doctor'])
|
|
->where('patient_id', $userId)
|
|
->whereDate('appointment_date', $today)
|
|
->whereIn('status', ['waiting', 'calling'])
|
|
->first(),
|
|
|
|
'history' => Appointment::with(['serviceCategory'])
|
|
->where('patient_id', $userId)
|
|
->where('appointment_date', '<', $today)
|
|
->orderBy('appointment_date', 'desc')
|
|
->take(3)
|
|
->get(),
|
|
|
|
'news' => News::where('is_published', true)
|
|
->latest() // Sama dengan orderBy('created_at', 'desc')
|
|
->take(3)
|
|
->get(),
|
|
]);
|
|
}
|
|
}
|