added assets into stream

This commit is contained in:
2026-06-27 15:51:44 +03:30
parent a0b3d8d3f5
commit 7b05db0ff0
6 changed files with 170 additions and 16 deletions
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace App\Services;
use App\Models\Customer;
class WalletBroadcastService
{
public function broadcastForCustomer(int $customerId, ?int $ownerType = null): void
{
$stream = app(PriceStreamService::class);
if (! $stream->isEnabled() || $customerId <= 0) {
return;
}
if ($ownerType === null || $ownerType <= 0) {
$ownerType = (int) Customer::query()->whereKey($customerId)->value('type');
}
if ($ownerType <= 0) {
$ownerType = 2;
}
$payload = app(AssetSummaryService::class)->buildForCustomer($customerId, $ownerType);
$stream->publishForCustomer($customerId, 'assets', $payload);
}
}