<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class SOSAlert extends Model
{
    protected $fillable = [
        'user_id', 'ride_id', 'latitude', 'longitude', 'address',
        'type', 'status', 'description',
        'resolved_at', 'responded_by', 'resolution',
    ];

    protected $casts = [
        'latitude' => 'float', 'longitude' => 'float',
        'resolved_at' => 'datetime',
    ];

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

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