<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class RouteDeviation extends Model
{
    protected $fillable = [
        'ride_id', 'user_id', 'driver_id',
        'expected_lat', 'expected_lng', 'actual_lat', 'actual_lng',
        'deviation_distance_meters', 'status',
        'detected_at', 'acknowledged_at', 'escalated_at', 'user_response',
    ];

    protected $casts = [
        'expected_lat' => 'float', 'expected_lng' => 'float',
        'actual_lat' => 'float', 'actual_lng' => 'float',
        'deviation_distance_meters' => 'float',
        'detected_at' => 'datetime', 'acknowledged_at' => 'datetime',
        'escalated_at' => 'datetime',
    ];

    public function ride() { return $this->belongsTo(Ride::class); }
    public function user() { return $this->belongsTo(User::class); }
    public function driver() { return $this->belongsTo(Driver::class); }
}
