Quality Validation - Dashboard - Production Quantity Validation and Plan Quantity Updation
This commit is contained in:
@@ -37,4 +37,23 @@ class ProductionQuantity extends Model
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::created(function ($productionQuantity) {
|
||||
$productionPlan = ProductionPlan::where('plant_id', $productionQuantity->plant_id)
|
||||
->where('shift_id', $productionQuantity->shift_id)
|
||||
->where('line_id', $productionQuantity->line_id)
|
||||
->whereDate('created_at',today())
|
||||
// ->where('plan_quantity', $productionQuantity->plan_quantity)
|
||||
->first();
|
||||
|
||||
if ($productionPlan) {
|
||||
$productionPlan->update([
|
||||
'production_quantity' => $productionPlan->production_quantity + 1,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user