2016-09-03 17:09:00 -04:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2017-04-14 20:46:50 -04:00
|
|
|
namespace Pterodactyl\Providers;
|
2016-09-03 17:09:00 -04:00
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Broadcast;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
use Pterodactyl\Models\User;
|
2016-09-03 17:09:00 -04:00
|
|
|
|
|
|
|
|
class BroadcastServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Bootstrap any application services.
|
|
|
|
|
*/
|
2023-02-23 12:30:16 -07:00
|
|
|
public function boot(): void
|
2016-09-03 17:09:00 -04:00
|
|
|
{
|
|
|
|
|
Broadcast::routes();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Authenticate the user's personal channel...
|
|
|
|
|
*/
|
2026-10-05 18:10:18 -04:00
|
|
|
Broadcast::channel('App.User.*', function (User $user, string $userId): bool {
|
|
|
|
|
$id = filter_var($userId, FILTER_VALIDATE_INT);
|
|
|
|
|
|
|
|
|
|
return $id !== false && $user->id === $id;
|
2016-09-03 17:09:00 -04:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|