From fe6890e94909affe6e78b4863407a0bf2a5494ff Mon Sep 17 00:00:00 2001 From: Loetwiek Date: Mon, 23 Dec 2024 20:49:12 +0100 Subject: [PATCH] Added page for pulse integration --- navigation.php | 1 + source/docs/v3/integrations/pulse.blade.md | 41 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 source/docs/v3/integrations/pulse.blade.md diff --git a/navigation.php b/navigation.php index fe542ea..d1f24d2 100644 --- a/navigation.php +++ b/navigation.php @@ -205,6 +205,7 @@ 'Passport' => 'integrations/passport', 'Nova' => 'integrations/nova', 'Telescope' => 'integrations/telescope', + 'Pulse' => 'integrations/pulse', 'Livewire' => 'integrations/livewire', 'Orchid' => 'integrations/orchid', 'Sanctum' => 'integrations/sanctum', diff --git a/source/docs/v3/integrations/pulse.blade.md b/source/docs/v3/integrations/pulse.blade.md new file mode 100644 index 0000000..b292deb --- /dev/null +++ b/source/docs/v3/integrations/pulse.blade.md @@ -0,0 +1,41 @@ +--- +title: Laravel Pulse integration +extends: _layouts.documentation +section: content +--- + +# Laravel Pulse {#laravel-pulse} + +To run Laravel Pulse in the main application, set the PULSE_DB_CONNECTION in the Pulse configuration file to point to the central database connection. + +If you need to resolve the user from the tenant database, you should create a custom user resolver that implements the ResolvesUsers interface. + +```php +class TenantUserResolver implements ResolvesUsers +{ + public function key($user): int|string|null + { + return implode(':', [tenant()->name, $user->name]); + } + + public function load(Collection $keys): self + { + return $this; + } + + public function find(int|string|null $key): object + { + [$tenant, $user] = explode(':', $key); + + return (object) [ + 'name' => $user, + 'extra' => $tenant, + ]; + } +} +``` + +Next, register this resolver in the AppServiceProvider: +```php +$this->app->singleton(ResolvesUsers::class, TenantUserResolver::class); +``` \ No newline at end of file