<?php

declare(strict_types=1);

namespace App\Models\Market;

use App\Models\Model;
use App\Models\User;

class CooperativeVote extends Model
{
    protected ?string $table = 'cooperative_votes';

    protected array $fillable = [
        'hashkey',
        'resolution_id',
        'user_id',
        'vote_cast',
        'created_by',
        'updated_by',
        'is_active',
    ];

    protected array $casts = [
        'is_active' => 'boolean',
    ];

    public function resolution()
    {
        return $this->belongsTo(CooperativeResolution::class, 'resolution_id');
    }

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

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

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