wasChanged('stock')) { $mapping = TikTokProductMapping::where('local_product_id', $product->id)->first(); if ($mapping) { // Dispatch background job to push updated stock to TikTok dispatch(function () use ($mapping, $product) { $service = app(TikTokShopService::class); $accessToken = config('services.tiktok.access_token'); // Or retrieved from DB $shopCipher = config('services.tiktok.shop_cipher'); $service->updateInventory( $accessToken, $shopCipher, $mapping->tiktok_sku_id, $product->stock ); }); } } } }