43 lines
883 B
PHP
43 lines
883 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Modules\Restaurant\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||
|
|
|
||
|
|
class Unit extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = [
|
||
|
|
'restaurant_id',
|
||
|
|
'user_id',
|
||
|
|
'name',
|
||
|
|
'short_name',
|
||
|
|
'type',
|
||
|
|
'base_unit_id',
|
||
|
|
'operator',
|
||
|
|
'operator_value',
|
||
|
|
'priority',
|
||
|
|
'version',
|
||
|
|
'is_default',
|
||
|
|
'status',
|
||
|
|
'created_at',
|
||
|
|
'updated_at',
|
||
|
|
'deleted_at',
|
||
|
|
];
|
||
|
|
|
||
|
|
public const TABLE_NAME = 'units';
|
||
|
|
|
||
|
|
protected $table = self::TABLE_NAME;
|
||
|
|
|
||
|
|
public function baseUnit(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Unit::class, 'base_unit_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function childUnits(): HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(Unit::class, 'base_unit_id');
|
||
|
|
}
|
||
|
|
}
|