<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens; 

class Voter extends Authenticatable
{
	use HasApiTokens;

    protected $table = 'voter';

    protected $fillable = ['name', 'no_kp', 'no_anggota','unit', 'election_id', 'alamat', 'telefon', 'saham', 'yuran', 'kehadiran','status_penyata','persetujuan','tarikh_sah','cadangan','pelaburan','tergempar','barangan','peribadi','berjamin_yuran','roadtax','pelbagai'];

    protected $casts = [
        'fizikal_registration_verified_at' => 'datetime',
    ];

    /**
     * Fizikal attendees must be counter-verified by admin; Maya does not use this gate.
     */
    public function isFizikalRegistrationVerifiedForVoting(): bool
    {
        if ((int) $this->kehadiran !== 1) {
            return true;
        }

        return $this->fizikal_registration_verified_at !== null;
    }
}
