<?php

namespace App\Http\Controllers\API\v1\Admin\Penyata;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Voter;


class GetController extends Controller
{
    public function index()
    {
        return Voter::select(
            'no_anggota',
            'name',
            'status_penyata',
            'tarikh_sah'
        )
            ->orderBy('no_anggota')
            ->get();
    }

    public function search(Request $request)
    {
        $query = Voter::query();

        if ($request->no_anggota) {
            $query->where('no_anggota', 'like', '%' . $request->no_anggota . '%');
        }

        return $query->paginate(10);
    }
}
