vendor = $vendor; $this->purchase_order = $purchase_order; } public function run() { /* Return immediately if status is not draft */ if ($this->purchase_order->status_id != PurchaseOrder::STATUS_DRAFT) { return $this->purchase_order; } $this->purchase_order->markInvitationsSent(); $this->purchase_order ->service() ->setStatus(PurchaseOrder::STATUS_SENT) ->applyNumber() ->adjustBalance($this->purchase_order->amount) //why was this commented out previously? ->save(); $subscriptions = Webhook::where('company_id', $this->purchase_order->company_id) ->where('event_id', Webhook::EVENT_SENT_PURCHASE_ORDER) ->exists(); if ($subscriptions) WebhookHandler::dispatch(Webhook::EVENT_SENT_PURCHASE_ORDER, $this->purchase_order, $this->purchase_order->company, 'vendor')->delay(0); return $this->purchase_order; } }