<?php

namespace App\Models;

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

class FranchiseZone extends Model
{
    use HasFactory;

    protected $fillable = [
        'state_map_id',
        'zone_number',
        'zone_name',
        'boundary_start_lat',
        'boundary_start_lng',
        'boundary_end_lat',
        'boundary_end_lng',
        'center_lat',
        'center_lng',
        'radius_km',
        'polygon_json',
    ];

    protected function casts(): array
    {
        return [
            'boundary_start_lat' => 'float',
            'boundary_start_lng' => 'float',
            'boundary_end_lat' => 'float',
            'boundary_end_lng' => 'float',
            'center_lat' => 'float',
            'center_lng' => 'float',
            'radius_km' => 'float',
            'polygon_json' => 'array',
        ];
    }

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