Replies: 2 comments
-
Help needed
|
Beta Was this translation helpful? Give feedback.
0 replies
-
You'll need to use the factory class for creating Loupe instances, and give it a separate data directory for each index to store data in. use Loupe\Loupe\Configuration;
use Loupe\Loupe\LoupeFactory;
$configuration = Configuration::create()->withPrimaryKey('uuid');
$loupe = (new LoupeFactory())->create(storage_path('app/loupe/products'), $configuration); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Setting Up Loupe Search in Laravel - Complete Guide
1. Installation
First, install the Loupe package via Composer:
2. Create Service Provider
Create a new service provider:
Update the service provider (
app/Providers/LoupeServiceProvider.php
):Register the provider in
config/app.php
:3. Add Dynamic Key Methods to Your Model
Update your model to dynamically return searchable, filterable, and sortable keys. Here's an example for the
Product
model:4. Create Searchable Trait
Add a trait to handle the indexing and searching logic:
5. Create Reindex Command
Create a new command:
Update the command (
app/Console/Commands/ReindexProducts.php
):Register the command in
app/Console/Kernel.php
:6. Usage
Initial Indexing
After setup, index your existing products:
Searching Products
Basic search:
Advanced search with options:
Deployment
Add to your deployment script:
7. Features Included
searchable
,filterable
, andsortable
keys8. Troubleshooting
If you encounter issues:
toSearchableArray()
keys match your model attributes.LoupeServiceProvider
correctly fetches keys from the model.--fresh
to clear the index before reindexing.storage/logs/laravel.log
).Beta Was this translation helpful? Give feedback.
All reactions