55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Modules\Restaurant\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
use Modules\Authentication\Models\User;
|
||
|
|
|
||
|
|
class FoodWaste extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = [
|
||
|
|
'restaurant_id',
|
||
|
|
'food_item_id',
|
||
|
|
'food_variant_id',
|
||
|
|
'quantity',
|
||
|
|
'unit_cost',
|
||
|
|
'reason',
|
||
|
|
'notes',
|
||
|
|
'wasted_by',
|
||
|
|
'approved_by',
|
||
|
|
'wasted_at',
|
||
|
|
'status',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'quantity' => 'decimal:2',
|
||
|
|
'unit_cost' => 'decimal:2',
|
||
|
|
'wasted_at' => 'datetime',
|
||
|
|
];
|
||
|
|
|
||
|
|
public const TABLE_NAME = 'food_wastes';
|
||
|
|
|
||
|
|
protected $table = self::TABLE_NAME;
|
||
|
|
|
||
|
|
public function product(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(FoodItem::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function variation(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(FoodVariant::class, 'food_variant_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function wastedBy(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(User::class, 'wasted_by');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function approvedByUser(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(User::class, 'approved_by');
|
||
|
|
}
|
||
|
|
}
|