<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Reservation extends Model
{
    //
    use SoftDeletes;
    protected $fillable = [
        'token','date','start_time','end_time','length_time','count_members','total','user_id','room_id'
    ];

    public function getShowDateAttribute()
    {
        $date = date('d',strtotime($this->date)) . ' ';
        $date .= __(date('F',strtotime($this->date))) . ' ';
        $date .= date('Y',strtotime($this->date));
        return $date;
    }

    public function user()
    {
        return $this->belongsTo(User::class)->withTrashed();
    }
    public function room()
    {
        return $this->belongsTo(Room::class)->withTrashed();
    }
    public function payment()
    {
        return $this->hasOne(ReservationPayment::class);
    }
}
