<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Booking extends Model
{
    protected $table = 'bookings';

    protected $fillable = [
        'booking_code',
        'guest_id',
        'room_id',
        'check_in',
        'check_out',
        'total_amount',
        'status'
    ];

    /**
     * Booking belongs to a guest
     */
    public function guest()
    {
        return $this->belongsTo(Guest::class, 'guest_id');
    }

    /**
     * Booking belongs to a room
     */
    public function room()
    {
        return $this->belongsTo(Room::class, 'room_id');
    }

    /**
     * Booking has one payment
     */
    public function payment()
    {
        return $this->hasOne(Payment::class, 'booking_id');
    }
}
