<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class AllowancePayout extends Model
{
    protected $table = 'allowance_payouts';

    protected $fillable = [
        'election_id',
        'voter_id',
        'method',
        'status',
        'amount_cents',
        'currency',
        'paid_by_admin_id',
        'paid_at',
        'reference',
        'note',
    ];

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

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

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

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

