hardcoded election_id on all kehadiran pages

This commit is contained in:
nurafrinaalimi16
2025-04-24 23:28:16 +08:00
parent 7539dbed25
commit 150d01975b
3 changed files with 57 additions and 108 deletions
+20 -16
View File
@@ -6,8 +6,6 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use App\Voter;
use Illuminate\Support\Facades\DB;
class FizikalController extends Controller
{
/**
@@ -15,27 +13,33 @@ class FizikalController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function index($id)
public function index()
{
//
$physicals = $this->getFizikalKehadiran($id);
$total_physicals = Voter::where('kehadiran', 1)->count();
$votes = Voter::where('election_id', $id)->count();
$voters = \App\Voter::where('election_id', $id)->get();
$electionId = 8;
// Get only voters who attended physically for election_id = 8
$physicals = Voter::where('election_id', $electionId)
->where('kehadiran', 1)
->get();
// Total physical attendees
$total_physicals = Voter::where('election_id', $electionId)
->where('kehadiran', 1)
->count();
// Total voters for the election
$votes = Voter::where('election_id', $electionId)->count();
// All voters for the election
$voters = Voter::where('election_id', $electionId)->get();
// Load PDF view
$pdf = App::make('dompdf.wrapper');
$pdf->loadView('report.fizikal', compact('physicals', 'voters','total_physicals','votes'));
$pdf->loadView('report.fizikal', compact('physicals', 'voters', 'total_physicals', 'votes'));
return $pdf->stream();
}
private function getFizikalKehadiran($id)
{
return \App\Voter::where('kehadiran', 1)->get();
}
/**
* Show the form for creating a new resource.
*