<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CupSize extends Model
{
    protected $fillable = [
        'name',
        'code',
        'scoop_count',
        'weight_grams',
        'price',
        'description',
        'is_active',
        'display_order',
    ];

    protected $casts = [
        'scoop_count' => 'integer',
        'weight_grams' => 'decimal:2',
        'price' => 'decimal:2',
        'is_active' => 'boolean',
        'display_order' => 'integer',
    ];

    /**
     * Scope to get only active cup sizes
     */
    public function scopeActive($query)
    {
        return $query->where('is_active', true);
    }

    /**
     * Scope to order by display order
     */
    public function scopeOrdered($query)
    {
        return $query->orderBy('display_order', 'asc');
    }
}
