partial update transaction work with stock product

This commit is contained in:
2025-06-24 19:42:19 +07:00
parent 33502e905d
commit c3233ea6b2
20 changed files with 3432 additions and 239 deletions

View File

@@ -47,4 +47,26 @@ class Product extends Model
{
return $this->stocks()->where('dealer_id', $dealerId)->first()?->quantity ?? 0;
}
/**
* Get all works that require this product
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function works()
{
return $this->belongsToMany(Work::class, 'work_products')
->withPivot('quantity_required', 'notes')
->withTimestamps();
}
/**
* Get work products pivot records
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function workProducts()
{
return $this->hasMany(WorkProduct::class);
}
}