Added production quantity update func. in production plan on success production transaction
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -44,10 +45,22 @@ class ProductionQuantity extends Model
|
||||
$productionPlan = ProductionPlan::where('plant_id', $productionQuantity->plant_id)
|
||||
->where('shift_id', $productionQuantity->shift_id)
|
||||
->where('line_id', $productionQuantity->line_id)
|
||||
->whereDate('created_at',today())
|
||||
->whereDate('created_at', today())
|
||||
// ->where('plan_quantity', $productionQuantity->plan_quantity)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if (!$productionPlan)
|
||||
{
|
||||
$productionPlan = ProductionPlan::where('plant_id', $productionQuantity->plant_id)
|
||||
->where('shift_id', $productionQuantity->shift_id)
|
||||
->where('line_id', $productionQuantity->line_id)
|
||||
->whereDate('created_at', Carbon::yesterday())
|
||||
// ->where('plan_quantity', $productionQuantity->plan_quantity)
|
||||
->latest()
|
||||
->first();
|
||||
}
|
||||
|
||||
if ($productionPlan) {
|
||||
$productionPlan->update([
|
||||
'production_quantity' => $productionPlan->production_quantity + 1,
|
||||
|
||||
Reference in New Issue
Block a user