purchase_order = $purchase_order; } public function run() { $line_items = $this->purchase_order->line_items; foreach ($line_items as $item) { $p = Product::query()->where('product_key', $item->product_key)->where('company_id', $this->purchase_order->company_id)->first(); if (!$p) { continue; } $p->in_stock_quantity += $item->quantity; $p->saveQuietly(); } $this->purchase_order->status_id = PurchaseOrder::STATUS_RECEIVED; $this->purchase_order->save(); return $this->purchase_order; } }