<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class AllowanceClaimCode extends Model
{
    protected $table = 'allowance_claim_codes';

    protected $fillable = [
        'election_id',
        'voter_id',
        'method',
        'code_hash',
        'code_last4',
        'expires_at',
        'used_at',
        'used_by_admin_id',
    ];

    protected $casts = [
        'expires_at' => 'datetime',
        'used_at' => 'datetime',
    ];

    public function election()
    {
        return $this->belongsTo(Election::class);
    }

    public function voter()
    {
        return $this->belongsTo(Voter::class);
    }

    public function usedByAdmin()
    {
        return $this->belongsTo(User::class, 'used_by_admin_id');
    }
}

