57 lines
1.2 KiB
PHP
57 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\Restaurant\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Modules\Authentication\Models\User;
|
|
|
|
class Stock extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'restaurant_id',
|
|
'ingredient_id',
|
|
'type',
|
|
'quantity',
|
|
'unit_cost',
|
|
'total_cost',
|
|
'reference_type',
|
|
'purchase_id',
|
|
'batch_no',
|
|
'expiry_date',
|
|
'added_by',
|
|
'remarks',
|
|
'status',
|
|
'created_at',
|
|
'updated_at',
|
|
'deleted_at',
|
|
];
|
|
|
|
public const TABLE_NAME = 'stocks';
|
|
|
|
protected $table = self::TABLE_NAME;
|
|
|
|
protected $casts = [
|
|
'expiry_date' => 'date:Y-m-d',
|
|
];
|
|
|
|
// 🔗 Relationships
|
|
public function ingredient(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Ingredient::class);
|
|
}
|
|
|
|
public function purchaseItem(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PurchaseItem::class, 'purchase_id');
|
|
}
|
|
|
|
public function addedBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'added_by');
|
|
}
|
|
}
|