<?php

namespace App\Models;

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

class Destination extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'flag',
        'description',
        'universities_count',
        'image',
        'country_code',
        'is_active',
        'sort_order',
        'additional_info'
    ];

    protected $casts = [
        'additional_info' => 'array',
        'is_active' => 'boolean',
        'universities_count' => 'integer',
        'sort_order' => 'integer'
    ];

    // Scope for active destinations
    public function scopeActive($query)
    {
        return $query->where('is_active', true);
    }

    // Scope for ordered destinations
    public function scopeOrdered($query)
    {
        return $query->orderBy('sort_order', 'asc')->orderBy('name', 'asc');
    }
}
