Package Data | |
---|---|
Maintainer Username: | zizohassan |
Maintainer Contact: | admin@5dmat-web.com (5dmatweb Team) |
Package Create Date: | 2017-03-04 |
Package Last Update: | 2018-02-09 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:13:51 |
Package Statistics | |
---|---|
Total Downloads: | 2,526 |
Monthly Downloads: | 17 |
Daily Downloads: | 1 |
Total Stars: | 50 |
Total Watchers: | 3 |
Total Forks: | 23 |
Total Open Issues: | 8 |
Full text search in laravel on single or multiple fields
composer require 5dmatwebsearch/advancesearch:dev-master
AdvanceSearch\AdvanceSearchProvider\AdvanceSearchProvider::class,
'Search' => AdvanceSearch\AdvanceSearchProvider\Facades\SearchFacades::class,
Add index to fields
php artisan index:table table fields
table = the table name fields = the fields you can add. One or more fields can be added like this: title,description,tags
Example
php artisan index:table films title,description
You can now use the search function
Search::search(modelName , fields, searchText ,select , order , pagination , limit)
modelName = The table name fields = The fields you can add title,description,tags searchText = The text you're looking for select = The fields you want a return from. You can return with one field like this: title. Or more than one like ['title' , 'description'] order = You can pass a single order field like this: id. Or you can pass the field and the way like this ['id' , 'desc'] pagination = True if you want pagination to be enabled, false if not. The package will paginate by default limit = The amount of results you want returned. (10 by default)
First example with pagination
Search::search(
"Films" ,
['title' , 'description'] ,
"Drama Outback GOLDFINGER" ,
['modelName' , 'title', 'description'],
['film_id' , 'asc'] ,
true ,
30
)
Second example with pagination
Search::search(
"Films" ,
['title' , 'description'] ,
"Drama Outback GOLDFINGER" ,
['id' , 'title', 'description'],
'film_id'
)
Example without pagination
Search::search(
"Films" ,
['title' , 'description'] ,
"Drama Outback GOLDFINGER" ,
['film_id' , 'title', 'description'],
'film_id',
false
)->where('film_id' , 10)->get()