{"repo":"spatie/laravel-searchable","free":true,"listed":false,"github":"https://github.com/spatie/laravel-searchable","clone":"git clone https://github.com/spatie/laravel-searchable.git","description":"Pragmatically search through models and other sources","language":"PHP","stars":1376,"topics":["search","laravel","php"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Laravel Searchable This package makes it easy to get structured search from a variety of sources. Here's an example where we search through some models. We already did some small preparation on the models themselves. The search will be performed case insensitive. $searchResults now contains all User models that contain john in the name attribute and BlogPost s that contain 'john' in the title attribute. In your view you can now loop over the search results: In this example we used models, but you can easily add a search aspect for an external API, list of files or an array of values. Support us We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products. We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall. Installation You can install the package via composer: Usage Preparing your models In order to search through models you'll have to let them implement the Searchable interface. You'll only need to add a getSearchResult method to each searchable model that must return an instance of SearchResult . Here's how it could look like for a blog post model. Searching models With the models prepared you can search them like this: The search will be performed case insensitive. $searchResults now contains all User models that contain john in th","default_branch":null,"files":null,"tree":[],"storefront":"/r/spatie","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/spatie/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."}