The service provider would ideally have a config to add a custom guard. Currently the file is like this:
<?php
namespace Statamic\Collaboration;
use Illuminate\Support\Facades\Broadcast;
use Statamic\Facades\User;
use Statamic\Providers\AddonServiceProvider;
use Statamic\Statamic;
class ServiceProvider extends AddonServiceProvider
{
protected $vite = [
'input' => ['resources/js/collaboration.js'],
'publicDirectory' => 'resources/dist',
'hotFile' => __DIR__.'/../resources/dist/hot',
];
public function bootAddon()
{
Statamic::provideToScript(['collaboration' => config('collaboration')]);
Broadcast::channel('entry.{id}.{site}', function ($user, $id, $site) {
$user = User::fromUser($user);
return [
'name' => $user->name(),
'id' => $user->id(),
'title' => $user->title(),
'email' => $user->email(),
'avatar' => $user->avatar(),
'initials' => $user->initials(),
];
});
}
}
However when using Eloquent Users in a different table it uses a separate auth guard so it needs something like this:
<?php
namespace Statamic\Collaboration;
use Illuminate\Support\Facades\Broadcast;
use Statamic\Facades\User;
use Statamic\Providers\AddonServiceProvider;
use Statamic\Statamic;
class ServiceProvider extends AddonServiceProvider
{
protected $vite = [
'input' => ['resources/js/collaboration.js'],
'publicDirectory' => 'resources/dist',
'hotFile' => __DIR__.'/../resources/dist/hot',
];
public function bootAddon()
{
Statamic::provideToScript(['collaboration' => config('collaboration')]);
Broadcast::channel('entry.{id}.{site}', function ($user, $id, $site) {
$user = User::fromUser($user);
return [
'name' => $user->name(),
'id' => $user->id(),
'title' => $user->title(),
'email' => $user->email(),
'avatar' => $user->avatar(),
'initials' => $user->initials(),
];
}, ['guards' => ['web', 'statamic']]);
}
}
The service provider would ideally have a config to add a custom guard. Currently the file is like this:
However when using Eloquent Users in a different table it uses a separate auth guard so it needs something like this: