<?php

namespace App\Models\Tour;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class TourPricing extends Model
{
    use HasFactory, SoftDeletes;

    protected $table = 'cultural_tour_pricings';

    protected $fillable = [
        'cultural_tour_id',
        'pricing_name',
        'description',
        'adult_price',
        'child_price',
        'infant_price',
        'child_min_age',
        'child_max_age',
        'infant_max_age',
        'currency',
        'sort_order',
        'is_active',
        'is_default',
    ];

    protected function casts(): array
    {
        return [
            'adult_price' => 'decimal:2',
            'child_price' => 'decimal:2',
            'infant_price' => 'decimal:2',
            'is_active' => 'boolean',
            'is_default' => 'boolean',
        ];
    }

    public function tour()
    {
        return $this->belongsTo(Tour::class, 'cultural_tour_id');
    }

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

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

    public function scopeOrdered($query)
    {
        return $query->orderBy('sort_order')->orderBy('pricing_name');
    }
}
