<?php

declare(strict_types=1);

namespace App\Models\Market;

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

class CooperativeResolution extends Model
{
    protected ?string $table = 'cooperative_resolutions';

    protected array $fillable = [
        'hashkey',
        'organization_id',
        'title',
        'description',
        'date_approved',
        'document_url',
        'status',
        'created_by',
        'updated_by',
        'is_active',
    ];

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

    public function organization()
    {
        return $this->belongsTo(Organization::class, 'organization_id');
    }

    public function votes()
    {
        return $this->hasMany(CooperativeVote::class, 'resolution_id');
    }

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

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