{"repo":"maize-tech/laravel-searchable","free":true,"listed":false,"github":"https://github.com/maize-tech/laravel-searchable","clone":"git clone https://github.com/maize-tech/laravel-searchable.git","description":"Easily add weighted searches through model attributes and relationships","language":"PHP","stars":113,"topics":["api","php","laravel","search","query","eloquent"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Laravel Searchable 🔍 Easily add weighted searches through model attributes and relationships. This package currently supports MySQL and PostgreSQL . Installation You can install the package via composer: You can publish the config file with: This is the content of the published config file: Usage To use the package, add the Maize\\Searchable\\HasSearch trait to each model you want to make searchable. Once done, you can implement the getSearchableAttributes abstract method by returning the list of attributes (or relationships' attributes) you want to search for. You can also define the weight of each searchable attribute. If no weight is specified then default match weight will be taken from config/searchable.php . Here's an example model including the HasSearch trait: Now you can just search for a given term using the scopeSearch scope method: That's all! The package generates an SQL query with an 'or' condition for each search term and each searchable fields. The given query returns all models matching the search terms. Furthermore, search results are weighted, which means the query will be ordered by the most matching models. If you don't want to order the search results by its match weight, you can set the orderByWeight flag to false: Testing Changelog Please see CHANGELOG for more information on what has changed recently. Contributing Please see CONTRIBUTING for details. Security Vulnerabilities Please review our security policy on how to report security vulnerabilities. C","default_branch":null,"files":null,"tree":[],"storefront":"/r/maize-tech","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/maize-tech/laravel-searchable/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}