94 lines
2.2 KiB
PHP
94 lines
2.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Modules\Booking\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||
|
|
use Modules\Authentication\Models\User;
|
||
|
|
use Modules\Restaurant\Models\Customer;
|
||
|
|
|
||
|
|
class Booking extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = [
|
||
|
|
'restaurant_id',
|
||
|
|
'hotel_id',
|
||
|
|
'customer_id',
|
||
|
|
'check_in',
|
||
|
|
'check_out',
|
||
|
|
'check_in_time',
|
||
|
|
'check_out_time',
|
||
|
|
'total_adults',
|
||
|
|
'total_children',
|
||
|
|
'subtotal_amount',
|
||
|
|
'tax_amount',
|
||
|
|
'discount_amount',
|
||
|
|
'total_amount',
|
||
|
|
'payment_status',
|
||
|
|
'payment_method',
|
||
|
|
'channel',
|
||
|
|
'status',
|
||
|
|
'canceled_at',
|
||
|
|
'canceled_by',
|
||
|
|
'remarks',
|
||
|
|
'created_at',
|
||
|
|
'updated_at',
|
||
|
|
'deleted_at',
|
||
|
|
];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Casts
|
||
|
|
*/
|
||
|
|
protected $casts = [
|
||
|
|
'restaurant_id' => 'integer',
|
||
|
|
'hotel_id' => 'integer',
|
||
|
|
'customer_id' => 'integer',
|
||
|
|
|
||
|
|
'check_in' => 'date',
|
||
|
|
'check_out' => 'date',
|
||
|
|
'check_in_time' => 'datetime:H:i',
|
||
|
|
'check_out_time' => 'datetime:H:i',
|
||
|
|
|
||
|
|
'total_adults' => 'integer',
|
||
|
|
'total_children' => 'integer',
|
||
|
|
|
||
|
|
'subtotal_amount' => 'decimal:2',
|
||
|
|
'tax_amount' => 'decimal:2',
|
||
|
|
'discount_amount' => 'decimal:2',
|
||
|
|
'total_amount' => 'decimal:2',
|
||
|
|
|
||
|
|
'canceled_at' => 'datetime',
|
||
|
|
'canceled_by' => 'integer',
|
||
|
|
];
|
||
|
|
|
||
|
|
public const TABLE_NAME = 'bookings';
|
||
|
|
|
||
|
|
protected $table = self::TABLE_NAME;
|
||
|
|
|
||
|
|
public function hotel(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Hotel::class)->select('id', 'name');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function customer(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Customer::class)->select('id', 'name', 'phone', 'email', 'avatar');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function bookingItems(): HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(BookingItem::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function rooms(): BelongsToMany
|
||
|
|
{
|
||
|
|
return $this->belongsToMany(Room::class, 'booking_items');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function canceledBy(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(User::class, 'canceled_by');
|
||
|
|
}
|
||
|
|
}
|