Download the PHP package teamtnt/laravel-scout-tntsearch-driver without Composer
On this page you can find all versions of the php package teamtnt/laravel-scout-tntsearch-driver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-scout-tntsearch-driver
TNTSearch Driver for Laravel Scout - Laravel 5.3 - 11
This package makes it easy to add full text search support to your models with Laravel 5.3 to 9.0.
Premium products
If you find TNT Search to be one of your valuable assets, take a look at one of our premium products
Support us on Open Collective
Contents
- Installation
- Usage
- Contributing
- Credits
- License
Installation
You can install the package via composer:
Add the service provider:
Ensure you have Laravel Scout as a provider too otherwise you will get an "unresolvable dependency" error
Add SCOUT_DRIVER=tntsearch
to your .env
file
Then you should publish scout.php
configuration file to your config directory
In your config/scout.php
add:
To prevent your search indexes being commited to your project repository,
add the following line to your .gitignore
file.
The asYouType
option can be set per model basis, see the example below.
Usage
After you have installed scout and the TNTSearch driver, you need to add the
Searchable
trait to your models that you want to make searchable. Additionaly,
define the fields you want to make searchable by defining the toSearchableArray
method on the model:
Then, sync the data with the search service like:
php artisan scout:import App\\Post
If you have a lot of records and want to speed it up you can run (note that with this you can no longer use model-relations in your toSearchableArray()
):
php artisan tntsearch:import App\\Post
After that you can search your models with:
Post::search('Bugs Bunny')->get();
Scout status
php artisan scout:status
With this simple command you'll get a quick overview of your search indices.
Or you can pass a searchable model argument:
php artisan scout:status "App\Models\Post"
If your models are not in the default location app
or one of its subdirectories, you may set the modelPath
option
Constraints
Additionally to where()
statements as conditions, you're able to use Eloquent queries to constrain your search. This allows you to take relationships into account.
If you make use of this, the search command has to be called after all queries have been defined in your controller.
The where()
statements you already know can be applied everywhere.
Adding via Query
The searchable()
method will chunk the results of the query and add the records to your search index.
When using constraints apply it after the constraints are added to the query, as seen in the above example.
OrderBy
An orderBy()
statement can now be applied to the search query similar to the where()
statement.
When using constraints apply it after the constraints are added to the query, as seen in the above example.
Sponsors
Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]
Credits
- Nenad Ticaric
- Sasa Tokic
- All Contributors
Contributors
This project exists thanks to all the people who contribute.
Backers
Thank you to all our backers! 🙏 [Become a backer]
All versions of laravel-scout-tntsearch-driver with dependencies
teamtnt/tntsearch Version 2.7.0|^2.8|^3.0|^4.0
laravel/scout Version 7.*|^8.0|^8.3|^9.0|^10
illuminate/bus Version ~5.4|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/contracts Version ~5.4|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/pagination Version ~5.4|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/queue Version ~5.4|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/support Version ~5.4|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0