<?php

namespace App\Models;

use App\Filters\MiscIssueFilters;
use Essa\APIToolKit\Filters\Filterable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class MiscIssue extends Model
{
    use HasFactory, Filterable, SoftDeletes;

    protected string $default_filters = MiscIssueFilters::class;

    protected $table = 'misc_issues';

    protected $fillable = [
        'document_no',
        'farm_id',
        'transaction_date',
        'transaction_type',
        'remarks',
        'user_id',
    ];

    public function miscIssueItem()
    {
        return $this->hasMany(MiscIssueItem::class, 'misc_issue_id', 'id');
    }

    public function farm()
    {
        return $this->belongsTo(Farm::class, 'farm_id', 'id');
    }
}
