first
This commit is contained in:
57
app/Http/Controllers/Admin/AttendanceController.php
Normal file
57
app/Http/Controllers/Admin/AttendanceController.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Concerns\SortsQuery;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\PusatMengundi;
|
||||
use App\Models\StaffAssignment;
|
||||
use App\Services\Attendance\AttendanceExportService;
|
||||
use App\Services\Attendance\AttendanceSummaryService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class AttendanceController extends Controller
|
||||
{
|
||||
use SortsQuery;
|
||||
|
||||
public function index(AttendanceSummaryService $summaryService): View
|
||||
{
|
||||
return view('admin.attendance.index', [
|
||||
'pusats' => $this->sortedQuery(
|
||||
PusatMengundi::query()->with(['election.settings']),
|
||||
['code', 'name'],
|
||||
'name'
|
||||
)->paginate(15)->withQueryString(),
|
||||
'summaryService' => $summaryService,
|
||||
]);
|
||||
}
|
||||
|
||||
public function show(PusatMengundi $pusatMengundi, AttendanceSummaryService $summaryService): View
|
||||
{
|
||||
$assignments = StaffAssignment::query()
|
||||
->with(['application', 'user', 'position', 'saluranMengundi', 'attendance.recordedBy'])
|
||||
->where('pusat_mengundi_id', $pusatMengundi->id)
|
||||
->where('status', 'active')
|
||||
->orderBy('position_id')
|
||||
->orderBy('saluran_mengundi_id')
|
||||
->get();
|
||||
|
||||
return view('admin.attendance.show', [
|
||||
'pusat' => $pusatMengundi->load('election.settings'),
|
||||
'assignments' => $assignments,
|
||||
'summary' => $summaryService->totalsForPusat($pusatMengundi),
|
||||
'roleSummaries' => $summaryService->roleTotalsForPusat($pusatMengundi),
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(PusatMengundi $pusatMengundi, Request $request, AttendanceExportService $exportService): StreamedResponse
|
||||
{
|
||||
$exportLog = $exportService->exportPusat($request->user(), $pusatMengundi);
|
||||
|
||||
return Storage::disk($exportLog->disk ?? 'local')
|
||||
->download($exportLog->path, $exportLog->file_name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user