No connection for Global content
Opened this issue · 4 comments
mikemartin commented
duncan412 commented
To expand a little bit on this, the auth ajax request throws an 403 error.
ben182 commented
Hi, as a workaround, put this in the boot method of any service provider:
Broadcast::channel('globals.{id}.{site}', function ($user, $id, $site) {
return [
'name' => $user->name(),
'id' => $user->id(),
'title' => $user->title(),
'email' => $user->email(),
'avatar' => $user->avatar(),
'initials' => $user->initials(),
];
});
theutz commented
Running into this problem, too, but the workaround doesn't seem to be working.
theutz commented
Running into this problem, too, but the workaround doesn't seem to be working.
Upon further investigation, it seems that the front-end is looking for a channel with four segments: globals.{set}.{id}.{site}
. I assume, at least, that this is what each of the segments mean.
- Broadcast::channel('globals.{id}.{site}', function ($user, $id, $site) {
+ Broadcast::channel('globals.{set}.{id}.{site}', function ($user, $set, $id, $site) {
So, to updated @ben182 's helpful comment from before, you might need to put the following in routes/channels.php
if you have it, or in the boot
method of the BroadcastServiceProvider
:
Broadcast::channel('globals.{set}.{id}.{site}', function ($user, $set, $id, $site) {
return [
'name' => $user->name(),
'id' => $user->id(),
'title' => $user->title(),
'email' => $user->email(),
'avatar' => $user->avatar(),
'initials' => $user->initials(),
];
});