PHPackages                             dalyio/laravel-search - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. dalyio/laravel-search

ActiveLibrary[Search &amp; Filtering](/categories/search)

dalyio/laravel-search
=====================

A package for Laravel to implement search bars on your application

17PHP

Since Jan 26Pushed 4y ago1 watchersCompare

[ Source](https://github.com/dalyio/laravel-search)[ Packagist](https://packagist.org/packages/dalyio/laravel-search)[ RSS](/packages/dalyio-laravel-search/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)DependenciesVersions (1)Used By (0)

Laravel Package to Implement Search Bars on Your Application
============================================================

[](#laravel-package-to-implement-search-bars-on-your-application)

A package for Laravel to add a search bar feature to your application. Easily add search capabilities on your Eloquent models by adding a search bar component to your application.

[![Latest Unstable Version](https://camo.githubusercontent.com/d06783c6fad18fd62ee9df067a4038e1703d7bf76c2590ada56f37f81d08bb4a/687474703a2f2f706f7365722e707567782e6f72672f64616c79696f2f6c61726176656c2d7365617263682f762f756e737461626c65)](https://packagist.org/packages/dalyio/laravel-search)[![PHP Version Require](https://camo.githubusercontent.com/e0e4fa217db233381a7e16257664740e02c40a387a5a0dfe55d40770f873a27e/687474703a2f2f706f7365722e707567782e6f72672f64616c79696f2f6c61726176656c2d7365617263682f726571756972652f706870)](https://packagist.org/packages/dalyio/laravel-search)[![License](https://camo.githubusercontent.com/9fb60b4b9bca686c4eca5639976bc8c30d66610da8a33197e7288ea23bb317a5/68747470733a2f2f706f7365722e707567782e6f72672f64616c79696f2f6c61726176656c2d7365617263682f6c6963656e7365)](https://packagist.org/packages/dalyio/laravel-search)

Installation
------------

[](#installation)

```
composer require dalyio/laravel-search
```

```
php artisan vendor:publish --provider="Dalyio\Search\Providers\SearchServiceProvider"
```

Configuration
-------------

[](#configuration)

Edit the new `search.php` configuration file in the config directory to configure your application's search bars. You may configure multiple search bars on a single application. The order in which the Eloquent models are provided will be a factor in determining the order of the search results.

```
return [
    // Default search namespace
    'default' => [
        'models' => [
            // Your searchable models
            App\Models\{YOUR SEARCHABLE MODEL}::class,
        ]
    ],

    // Choose any namespace you want to configure multiple searchbars
    // Namespaces of searchbars are assigned on the component tag
    'additional_namespace' => [
        'models' => [
            App\Models\{YOUR SEARCHABLE MODEL}::class,
        ]
    ],
]
```

Usage
-----

[](#usage)

### Search Bar Component

[](#search-bar-component)

Insert the blade search bar component into your view. The namespace corresponds to the namespace you set in the configuration file. These parameters are all optional.

```

```

### Searchable Eloquent Models

[](#searchable-eloquent-models)

Specify which attributes to apply searches to on the Eloquent models by adding a *$searchable* property. Omitting this property will cause all fields of the Eloquent model to be searched upon.

```
    protected $searchable = [
        'first_name', 'last_name'
    ];
```

Add the *toSearch()* method to an Eloquent mode to properly format the search results and set the link url. Omitting this method will cause the format of the results to not work properly.

```
    public function toSearch()
    {
        return array_merge(parent::toArray(), [
            'search_header_format' => 'NFL Player',
            'search_result_format' => ''.$this->firstName().' '.$this->lastName().' ('.$this->position().')',
            'search_url' => 'https://www.pro-football-reference.com/players/'.strtoupper(substr($this->lastName(), 0, 1)).'/'.$this->frKey().'.htm',
        ]);
    }
```

### Styling

[](#styling)

The search package comes with default styling to match Laravel's out-of-box welcome page. To implement custom styling rules you can set the default styling to *false* on the blade component and implement custom rules.

```

```

Add the following rules and customizations to your application's main css files.

```
#search-bar-component {
    position: relative;
}
#search-bar-component input#search-bar {
    display: block;
    position: absolute;
    right: 0;
    cursor: text;
    height: 2rem;
    color: #4e6e8e;
    border: 1px solid #cfd4db;
    border-radius: 2rem;
    font-size: .9rem;
    line-height: 2rem;
    padding: 0 1rem;
    outline: 0;
    background-size: auto;
    background-size: 1rem;
    transition: all .2s ease;
}
#search-bar-component #dropdown-menu {
    display: none;
    position: absolute;
    top: 2rem;
    right: 0;
    border-radius: 1rem;
    text-align: left;
    min-width: 400px;
    background: #fff;
    border: 1px solid #cfd4db;
    transition: all .2s ease;
}
#search-bar-component #dropdown-menu .result-link {
    display: block;
    padding: .750rem 1rem;
    font-size: .875rem;

}
#search-bar-component #dropdown-menu .result-link:hover,
#search-bar-component #dropdown-menu .result-link:active {
    background-color: #f1f2f4;
}
#search-bar-component #dropdown-menu .result-header,
#search-bar-component #dropdown-menu .result-empty {
    padding: 1rem;
    width: 100%;
}
#search-bar-component #dropdown-menu .result-header {
    border-bottom: 1px solid #cfd4db;
}
```

License
-------

[](#license)

Laravel Search is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b8ca2eef70c13f1da167ef8169d86c45ad57bde60719f84e0da464ff989b6099?d=identicon)[dalyio](/maintainers/dalyio)

---

Top Contributors

[![dalyio](https://avatars.githubusercontent.com/u/64324039?v=4)](https://github.com/dalyio "dalyio (17 commits)")

---

Tags

laravelphpsearch

### Embed Badge

![Health badge](/badges/dalyio-laravel-search/health.svg)

```
[![Health](https://phpackages.com/badges/dalyio-laravel-search/health.svg)](https://phpackages.com/packages/dalyio-laravel-search)
```

###  Alternatives

[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[massive/search-bundle

Massive Search Bundle

721.4M13](/packages/massive-search-bundle)[outl1ne/nova-multiselect-filter

Multiselect filter for Laravel Nova.

45802.7k3](/packages/outl1ne-nova-multiselect-filter)[handcraftedinthealps/zendsearch

a general purpose text search engine written entirely in PHP 5

39921.0k35](/packages/handcraftedinthealps-zendsearch)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
