mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-05 12:08:58 +00:00
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
use App\Models\Node;
|
|
use App\Models\Payment;
|
|
use Illuminate\Support\Facades\Broadcast;
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Broadcast Channels
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Here you may register all of the event broadcasting channels that your
|
|
| application supports. The given channel authorization callbacks are
|
|
| used to check if an authenticated user can listen to the channel.
|
|
|
|
|
*/
|
|
|
|
// 支付状态更新频道
|
|
Broadcast::channel('payment-status.{tradeNo}', static function ($user, $tradeNo) {
|
|
// 检查订单是否属于该用户
|
|
return Payment::uid()->whereTradeNo($tradeNo)->exists();
|
|
});
|
|
|
|
// 节点相关操作频道
|
|
Broadcast::channel('node.{type}.{nodeId}', static function ($user, $type, $nodeId) {
|
|
// 验证用户权限和节点访问权限
|
|
if (! $user->can("admin.node.$type")) {
|
|
return false;
|
|
}
|
|
|
|
// 如果是特定节点操作,验证节点存在性和访问权限
|
|
if ($nodeId !== 'all') {
|
|
return Node::where('id', $nodeId)->exists();
|
|
}
|
|
|
|
return true;
|
|
});
|