<?php

namespace App\Models;

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

class StateMap extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'slug',
        'state_code',
        'latitude',
        'longitude',
        'zoom_level',
        'traffic_level',
        'traffic_summary',
    ];

    protected function casts(): array
    {
        return [
            'latitude' => 'float',
            'longitude' => 'float',
            'zoom_level' => 'integer',
        ];
    }

    public function getRouteKeyName(): string
    {
        return 'slug';
    }

    public function franchiseZones(): HasMany
    {
        return $this->hasMany(FranchiseZone::class)->orderBy('zone_number');
    }
}
