This commit is contained in:
Andras Bacsai 2023-12-05 15:19:54 +01:00
parent e0cefc787a
commit d59ec2548a
3 changed files with 19 additions and 12 deletions

View File

@ -13,14 +13,16 @@
class TestEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $teamId;
public function __construct()
{
$this->teamId = auth()->user()->currentTeam()->id;
}
public function broadcastOn(): array
{
return [
new Channel('public'),
new PrivateChannel("custom.{$this->teamId}"),
];
}
}

View File

@ -10,12 +10,17 @@ class Dashboard extends Component
{
public $projects = [];
public $servers = [];
protected $listeners = ['echo:public,TestEvent' => 'notifyNewOrder'];
public function notifyNewOrder()
{
$this->emit('success', 'New order received!');
}
// public function getListeners()
// {
// $teamId = auth()->user()->currentTeam()->id;
// return [
// "echo-private:custom.{$teamId},TestEvent" => 'notifyNewOrder',
// ];
// }
// public function notifyNewOrder()
// {
// $this->emit('success', 'New order received!');
// }
public function mount()
{
$this->servers = Server::ownedByCurrentTeam()->get();

View File

@ -38,12 +38,12 @@
use Laravel\Fortify\Contracts\FailedPasswordResetLinkRequestResponse;
use Laravel\Fortify\Contracts\SuccessfulPasswordResetLinkRequestResponse;
use Laravel\Fortify\Fortify;
Route::get('/fire', function () {
event(new \App\Events\TestEvent());
return 'fired';
});
if (isDev()) {
if (isDev()) {
Route::get('/fire', function () {
event(new \App\Events\TestEvent());
return 'fired';
});
Route::get('/dev/compose', Compose::class)->name('dev.compose');
}
Route::post('/forgot-password', function (Request $request) {