fix status hantar emel dan jana sijil

This commit is contained in:
Saufi
2026-05-20 10:20:59 +08:00
parent 899507070c
commit 7027651dd7
12 changed files with 240 additions and 141 deletions

View File

@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Certificate;
use App\Models\EmailLog;
use App\Models\Participant;
use App\Models\Program;
use App\Models\ProgramParticipant;
@@ -42,20 +41,13 @@ class ParticipantController extends Controller
$programParticipants = $query->paginate(20)->withQueryString();
// Load certificates and latest email logs for displayed participants
// Load certificates for displayed participants
$participantIds = $programParticipants->pluck('participant_id');
$certificates = Certificate::where('program_id', $program->id)
->whereIn('participant_id', $participantIds)
->get()
->keyBy('participant_id');
$certIds = $certificates->pluck('id');
$emailLogs = EmailLog::whereIn('certificate_id', $certIds)
->orderByDesc('id')
->get()
->groupBy('certificate_id')
->map->first();
$countRow = DB::table('program_participants')
->where('program_id', $program->id)
->selectRaw("COUNT(*) as total, SUM(is_pre_registered) as pre_registered, SUM(registration_source = 'walk_in') as walk_in, SUM(status = 'checked_in') as checked_in")
@@ -68,7 +60,7 @@ class ParticipantController extends Controller
'checked_in' => (int) ($countRow->checked_in ?? 0),
];
return view('admin.programs.participants.index', compact('program', 'programParticipants', 'counts', 'certificates', 'emailLogs'));
return view('admin.programs.participants.index', compact('program', 'programParticipants', 'counts', 'certificates'));
}
public function create(Program $program): View