Download the PHP package muhaimenul/lara-search without Composer
On this page you can find all versions of the php package muhaimenul/lara-search. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download muhaimenul/lara-search
More information about muhaimenul/lara-search
Files in muhaimenul/lara-search
Package lara-search
Short Description An eloquent model searching package with various searching configuration.
License MIT
Informations about the package lara-search
LaraSearch
About LaraSearch (Laravel Search)
LaraSearch (Laravel Search) is a Laravel package that adds various searching functionalities to Eloquent Models. This package makes it easy to get structured search from a variety of sources and provides varieties of configurations and options to select for searching, such as:
- Simple search
- MySQL Full-text search
- Elastic like search (Future Improvement)
Installation
You can install the package via composer:
Usage
Preparing your models
Add the trait to your model and columns as your search rules.
Searching models
With the models prepared you can search them like this:
Search like default queries
This Search methos is compatable with any eloquent methods and Paginatation like laravel default queries. Such as,
Simple Search
Simple search uses eloquent WHERE and sql LIKE operator to search for a specified pattern in a column. By default, this package uses it and No additional configuration is needed. Just follow above instructions to use Simple Search.
MySQL Full-text Search
Full-Text Search in MySQL server lets users run full-text queries against character-based data in MySQL tables. It is a powerful features that allows searching text efficiently accross multiple columns. It provides searching functionalites like Algolia but more native to MySQL. To learn more see here. From version 4, Laravel doesn't support FULLTEXT indexes by default. So, a full-text index must be created on the table before running full-text queries on a table.
If you want to use it, then you will have to publish to package in order to enable it from config.
Publishing
You can publish everything at once:
Configuration
After publishing the package you will find, larasearch.php
configuration file in the config
folder.
Here, the 'formula
' is the key to determine this project's search type. Currently there are two types of configuration, 'fulltext
' (FullText Search) and 'like
' (Simple Search).
You can directly assign formula type in larasearch.php
or use .env
and assign value to 'LARA_SEARCH_TYPE' alias.
By default, this package uses FullText Search, you have to publish the package and follow below configuration.
Setup Full-Text Search
To use Full-text search, only additional full-text index is needed. Rest of the searching process is same.
- Fulltext search can only be used with MySQL 5.6+, else the Database Engine must be set to MyISAM instead of InnoDB.
- Then set up the migration and add the Full-Text index.
NOTE: Here, fulltext_index (first_name, last_name, email)
must have to be same as the protected $searchable
columns / array added in the model.
Then, run the migrations.
VoalΓ‘! The setup is done. Now The powrfull fulltext search can be used easily by this package following the initial usage.
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you discover a security vulnerability or bugs within LaraSearch, please send an e-mail to Muhaimenul Islam via [email protected].
Credits
License
The LaraSearch package is open-sourced project licensed under the MIT license.