mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24:03 +00:00
20 lines
777 B
Markdown
20 lines
777 B
Markdown
---
|
|
title: Laravel Scout integration
|
|
extends: _layouts.documentation
|
|
section: content
|
|
---
|
|
|
|
# Laravel Scout {#laravel-scout}
|
|
> 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`:
|
|
|
|
```php
|
|
config(['scout.prefix' => tenant()->getTenantKey()]);
|
|
```
|
|
|
|
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"
|
|
```
|