This package is abandoned and no longer maintained. No replacement package was suggested.

Search eloquent models and filter matching results for a url get request

1.0.8 2020-06-18 15:24 UTC

This package is auto-updated.

Last update: 2021-04-23 12:33:44 UTC


Latest Version on Packagist Build Status StyleCI Scrutinizer Code Quality Total Downloads

A package to make searching eloquent models from a single search field easier


You can install the package via composer:

composer require macsidigital/laravel-searchable

The service provider should automatically register for For Laravel > 5.4.

For Laravel < 5.5, open config/app.php and, within the providers array, append:



Create 2 arrays in your elequent model, the first with the fields that can be sorted, the second showing any table joins.

protected $searchable = [
    'name', 'email', 

protected $extended_joins = [
    '' => [
        'table_field' => '',
        'foreign_table_field' => 'addresses.addressable_id',
        'restrict_table_field' => 'addresses.addressable_type',
        'restrict_value' => 'App\User'

If no table joins are required then you will only need the searchable array.

For any joins include the table and field seperated by a period (.).

Then to search the fields simply add a form and input named 'search' into your page that uses a get request. Use the @searchableformurl to create the form request

<form class="inline-form" action="@searchableformurl()" method="GET">
	<div class="input-group">
	  <input type="text" class="form-control" placeholder="Search" aria-label="Search" aria-describedby="search" name="search">
	  <div class="input-group-append">
	    <button class="btn btn-outline-secondary" type="submit" id="search"><i class="fas fa-search"></i></button>


Please see CHANGELOG for more information what has changed recently.


Please see CONTRIBUTING for details.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.