95 lines
2.1 KiB
PHP
95 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Authentication\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Modules\Restaurant\Models\DeliveryCharge;
|
|
use Modules\Restaurant\Models\Order;
|
|
use Modules\Restaurant\Models\RestaurantSchedule;
|
|
use Modules\Restaurant\Models\Zone;
|
|
|
|
class Restaurant extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
public const TABLE_NAME = 'restaurants';
|
|
|
|
protected $fillable = [
|
|
'restaurant_id',
|
|
'owner_id',
|
|
'assigned_to',
|
|
'name',
|
|
'email',
|
|
'address',
|
|
'restaurant_type',
|
|
'phone',
|
|
'domain',
|
|
'platform',
|
|
'last_active_time',
|
|
'logo',
|
|
'status',
|
|
'theme_id',
|
|
'created_at',
|
|
'updated_at',
|
|
'deleted_at',
|
|
];
|
|
|
|
/**
|
|
* Attribute Casting
|
|
*/
|
|
protected $casts = [
|
|
'owner_id' => 'integer',
|
|
'assigned_to' => 'integer',
|
|
'last_active_time' => 'datetime',
|
|
'status' => 'boolean',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
'deleted_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* Get the owner of the restaurant.
|
|
*/
|
|
public function owner(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'owner_id');
|
|
}
|
|
|
|
/**
|
|
* Get the user assigned to this restaurant.
|
|
*/
|
|
public function assignedUser(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'assigned_to');
|
|
}
|
|
|
|
public function subscription(): HasOne
|
|
{
|
|
return $this->hasOne(Subscription::class, 'restaurant_id', 'id')->with('package');
|
|
}
|
|
|
|
public function zone(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Zone::class);
|
|
}
|
|
|
|
public function schedules(): HasMany
|
|
{
|
|
return $this->hasMany(RestaurantSchedule::class);
|
|
}
|
|
|
|
public function deliveryCharges(): HasMany
|
|
{
|
|
return $this->hasMany(DeliveryCharge::class);
|
|
}
|
|
|
|
public function orders(): HasMany
|
|
{
|
|
return $this->hasMany(Order::class);
|
|
}
|
|
}
|