partial update create mutations
This commit is contained in:
@@ -24,9 +24,20 @@ class Product extends Model
|
||||
return $this->hasMany(Stock::class);
|
||||
}
|
||||
|
||||
public function mutationDetails()
|
||||
{
|
||||
return $this->hasMany(MutationDetail::class);
|
||||
}
|
||||
|
||||
// Helper method untuk mendapatkan total stock saat ini
|
||||
public function getCurrentTotalStockAttribute()
|
||||
{
|
||||
return $this->stocks()->sum('quantity');
|
||||
}
|
||||
|
||||
// Helper method untuk mendapatkan stock di dealer tertentu
|
||||
public function getStockByDealer($dealerId)
|
||||
{
|
||||
return $this->stocks()->where('dealer_id', $dealerId)->first()?->quantity ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user