<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;

class Booking extends BaseModel
{
    protected function casts(): array
    {
        return [
            'check_in' => 'date', 'check_out' => 'date', 'base_price' => 'decimal:2',
            'cleaning_fee' => 'decimal:2', 'service_fee' => 'decimal:2',
            'total_price' => 'decimal:2', 'confirmed_at' => 'datetime',
            'cancelled_at' => 'datetime',
        ];
    }

    public function listing(): BelongsTo { return $this->belongsTo(Listing::class); }
    public function user(): BelongsTo { return $this->belongsTo(User::class); }
    public function payment(): HasOne { return $this->hasOne(Payment::class); }
    public function review(): HasOne { return $this->hasOne(Review::class); }
}