businessOrderItem = $item->toArray(); $this->num = $num; $this->updateStock(); } private function updateStock() { [$goodsCode, $skuCode] = explode('_', $this->businessOrderItem['external_sku_id']); $this->goodsSku = GoodsSku::query()->where('sku_code', $skuCode) ->whereHas('goods', function ($query) use ($goodsCode) { $query->where('goods_code', $goodsCode); }) ->first(); if ($this->goodsSku) { $this->goodsSku->stock += $this->num; $this->goodsSku->save(); } } /** * Get the channels the event should broadcast on. * * @return \Illuminate\Broadcasting\Channel|array */ public function broadcastOn() { return new PrivateChannel('channel-name'); } }