DONE: centralize theme color, interactive dashboard, increase winner result, refer TODO
This commit is contained in:
@@ -113,6 +113,47 @@ class GetController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
// Vote status: 1 = has voted, 0 = has not voted (for this election)
|
||||
$hasVoted = request('has_voted');
|
||||
if ($hasVoted !== null && $hasVoted !== '') {
|
||||
$hv = (string) $hasVoted;
|
||||
if ($hv === '1' || $hv === 'true' || $hv === 'yes') {
|
||||
$q->whereExists(function ($sub) use ($electionId) {
|
||||
$sub->from('result')
|
||||
->whereColumn('result.voter_id', 'voter.id')
|
||||
->where('result.election_id', $electionId);
|
||||
});
|
||||
} elseif ($hv === '0' || $hv === 'false' || $hv === 'no') {
|
||||
$q->whereNotExists(function ($sub) use ($electionId) {
|
||||
$sub->from('result')
|
||||
->whereColumn('result.voter_id', 'voter.id')
|
||||
->where('result.election_id', $electionId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Cash allowance payment status (matches admin "Status" column: cash_paid_at)
|
||||
$cashStatus = request('cash_status');
|
||||
if ($cashStatus !== null && $cashStatus !== '') {
|
||||
if ($cashStatus === 'paid') {
|
||||
$q->whereExists(function ($sub) use ($electionId) {
|
||||
$sub->from('allowance_payouts')
|
||||
->whereColumn('allowance_payouts.voter_id', 'voter.id')
|
||||
->where('allowance_payouts.election_id', $electionId)
|
||||
->where('allowance_payouts.method', 'cash')
|
||||
->where('allowance_payouts.status', 'paid');
|
||||
});
|
||||
} elseif ($cashStatus === 'unpaid') {
|
||||
$q->whereNotExists(function ($sub) use ($electionId) {
|
||||
$sub->from('allowance_payouts')
|
||||
->whereColumn('allowance_payouts.voter_id', 'voter.id')
|
||||
->where('allowance_payouts.election_id', $electionId)
|
||||
->where('allowance_payouts.method', 'cash')
|
||||
->where('allowance_payouts.status', 'paid');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Return all voters with pagination
|
||||
return $q->paginate(1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user