<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Models\FuelLog;

class TripLog extends Model
{
    protected $fillable = [
        'user_id',
        'vehicle_id',
        'departure_time',
        'return_time'
    ];

    protected $casts = [
        'departure_time' => 'datetime',
        'return_time' => 'datetime',
    ];

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

    public function vehicle()
    {
        return $this->belongsTo(Vehicle::class);
    }

    public function fuelLogs()
    {
        return $this->hasMany(FuelLog::class, 'trip_id');
    }
}