<?php

namespace App\Models;

use App\Core\Traits\HasUuid;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class BillVariation extends Model
{
    use HasUuid;

    protected $fillable = [
        'bill_service_id',
        'name',
        'code',
        'amount',
        'discount',
        'is_active',
        'sort_order',
        'metadata',
    ];

    protected function casts(): array
    {
        return [
            'amount' => 'decimal:2',
            'discount' => 'decimal:2',
            'is_active' => 'boolean',
            'metadata' => 'array',
        ];
    }

    public function billService(): BelongsTo
    {
        return $this->belongsTo(BillService::class);
    }

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