28 lines
718 B
PHP
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);
|
||
|
|
}
|
||
|
|
}
|