Files
boursecu_server/app/Services/WalletBroadcastService.php
T
2026-06-27 15:51:44 +03:30

28 lines
718 B
PHP

<?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);
}
}