<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Pasture extends Model
{
    protected $fillable = [
        'name',
        'code',
        'active',
        'notes',
        'sort_order',
    ];

    protected $casts = [
        'active' => 'boolean',
        'sort_order' => 'integer',
    ];

    public function cattle(): HasMany
    {
        return $this->hasMany(Cattle::class);
    }

    public function scopeActive($query)
    {
        return $query->where('active', true);
    }
}
