<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;

class LookupList extends Model
{
    protected $fillable = ['farm_id', 'list_type', 'value', 'label', 'sort_order', 'is_active'];

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

    public static function valuesFor(string $type): Collection
    {
        return static::where('farm_id', 1)
            ->where('list_type', $type)
            ->where('is_active', true)
            ->orderBy('sort_order')
            ->orderBy('label')
            ->pluck('value');
    }

    public static function optionsFor(string $type): Collection
    {
        return static::where('farm_id', 1)
            ->where('list_type', $type)
            ->where('is_active', true)
            ->orderBy('sort_order')
            ->orderBy('label')
            ->get(['value', 'label']);
    }
}
