<?php

namespace App\Http\Controllers\API\v1;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Voter;

/**
 * Unauthenticated list of physical (Fizikal) attendees for roulette / display.
 */
class RouletteFizikalVotersController extends Controller
{
    public function __invoke()
    {
        $electionId = Util::getCurrentElection();

        $voters = Voter::query()
            ->where('election_id', $electionId)
            ->where('kehadiran', 1)
            ->orderBy('no_anggota')
            ->get(['id', 'name', 'no_anggota']);

        return response()->json([
            'voters' => $voters,
        ]);
    }
}
