mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 02:04:03 +00:00
Update Scout integration page
This commit is contained in:
parent
1d68074412
commit
10851f7469
1 changed files with 7 additions and 8 deletions
|
|
@ -7,19 +7,18 @@ section: content
|
||||||
# Laravel Scout {#laravel-scout}
|
# Laravel Scout {#laravel-scout}
|
||||||
> Note: Make sure the Scout config file is published
|
> Note: Make sure the Scout config file is published
|
||||||
|
|
||||||
After [installing Scout](https://laravel.com/docs/9.x/scout#installation), make sure the models of all tenants aren't being imported in the same index by prefixing the model indices with the current tenant's key. You can achieve that by adding a listener with this code to the `TenancyInitialized` event in your `TenancyServiceProvider`:
|
After [installing Scout](https://laravel.com/docs/9.x/scout#installation), add `ScoutTenancyBootstrapper` to the bootstrappers in your Tenancy config (`config/tenancy.php`):
|
||||||
|
|
||||||
```php
|
```php
|
||||||
config(['scout.prefix' => tenant()->getTenantKey()]);
|
'bootstrappers' => [
|
||||||
|
...
|
||||||
|
Stancl\Tenancy\Bootstrappers\Integrations\ScoutTenancyBootstrapper::class,
|
||||||
|
],
|
||||||
```
|
```
|
||||||
|
|
||||||
And to reset the prefix as tenancy ends, add a listener with this code to the `TenancyEnded` event:
|
This makes sure the models of all tenants aren't being imported in the same index by prefixing the model indices with the current tenant's key.
|
||||||
|
|
||||||
```php
|
You can import your existing records for each tenant using the `tenants:run` command:
|
||||||
config(['scout.prefix' => '']);
|
|
||||||
```
|
|
||||||
|
|
||||||
After that, you can import your existing records for each tenant using the `tenants:run` command:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
php artisan tenants:run scout:import --argument="model=App\Models\YourSearchableModel"
|
php artisan tenants:run scout:import --argument="model=App\Models\YourSearchableModel"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue