88 lines
1.9 KiB
PHP
88 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Modules\Restaurant\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Modules\Authentication\Models\User;
|
|
|
|
class Order extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'restaurant_id',
|
|
'table_id',
|
|
'waiter_id',
|
|
'driver_id',
|
|
'customer_id',
|
|
'payment_method_id',
|
|
'order_number',
|
|
'reference',
|
|
'order_type',
|
|
'status',
|
|
'subtotal',
|
|
'discount',
|
|
'tax',
|
|
'service_charge',
|
|
'tip_amount',
|
|
'grand_total',
|
|
'payment_status',
|
|
'payment_reference',
|
|
'paid_at',
|
|
'order_date',
|
|
'preparation_time',
|
|
'ready_at',
|
|
'handed_over_at',
|
|
'delivered_at',
|
|
'estimated_ready_time',
|
|
'delivery_address',
|
|
'order_source',
|
|
'meta',
|
|
'added_by',
|
|
'cancelled_at',
|
|
'cancel_reason',
|
|
'cancelled_by',
|
|
'updated_by',
|
|
'created_at',
|
|
'updated_at',
|
|
'deleted_at',
|
|
];
|
|
|
|
public const TABLE_NAME = 'orders';
|
|
|
|
protected $table = self::TABLE_NAME;
|
|
|
|
protected $casts = [
|
|
'payment_status' => 'boolean',
|
|
'meta' => 'array',
|
|
];
|
|
|
|
public function items(): HasMany
|
|
{
|
|
return $this->hasMany(OrderItem::class)->with('food');
|
|
}
|
|
|
|
public function table(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Table::class);
|
|
}
|
|
|
|
public function customer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function waiter(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'waiter_id');
|
|
}
|
|
|
|
public function paymentMethod(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PaymentMethod::class);
|
|
}
|
|
}
|