<?php

namespace App\Models;

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

class TravelPolicy extends Model
{
    use HasFactory;

    protected $fillable = [
        'corporate_account_id',
        'name',
        'description',
        'max_ride_cost',
        'allowed_ride_types',
        'blackout_dates',
        'pre_approval_required',
        'approval_required_above_amount',
        'restricted_areas',
    ];

    protected $casts = [
        'max_ride_cost' => 'decimal:2',
        'allowed_ride_types' => 'json',
        'blackout_dates' => 'json',
        'pre_approval_required' => 'boolean',
        'approval_required_above_amount' => 'decimal:2',
        'restricted_areas' => 'json',
    ];

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