PHPackages                             hanieas/larasearch - 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. [Database &amp; ORM](/categories/database)
4. /
5. hanieas/larasearch

ActiveLibrary[Database &amp; ORM](/categories/database)

hanieas/larasearch
==================

0.0.1(2y ago)34PHPPHP ^8.2

Since Nov 20Pushed 2y ago1 watchersCompare

[ Source](https://github.com/hanieas/Larasearch)[ Packagist](https://packagist.org/packages/hanieas/larasearch)[ RSS](/packages/hanieas-larasearch/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

LaraSearch
==========

[](#larasearch)

This is a search package built to easily integrate with Laravel and the database.

Installation
============

[](#installation)

```
composer require hanieas/larasearch
```

Usage
=====

[](#usage)

Prepare Model
-------------

[](#prepare-model)

In order to search through models you'll have to let them implement the Searchable interface.

```
namespace LaraSearch;

interface Searchable
{
    /**
     * @return array
     */
    public function getColumnsForExactMatch(): array;

    /**
     * @return array
     */
    public function getColumnsForLikeMatch(): array;

    /**
     * @return array
     */
    public function getColumnsForBooleanMatch(): array;

    /**
     * @return array
     */
    public function getColumnsForPeriodMatch(): array;
}
```

You need to add the below 4 functions in your model to define type of search for columns of your table. This package will search items that are in the fillable attribute of the model.

```
use LaraSearch\Searchable;

class User extends Model implements Searchable
{
    protected $fillable = [
        'username',
        'mobile',
        'is_active',
        'logged_in',
    ];

    /**
     * @return array
     */
    public function getColumnsForExactMatch(): array {
        return [
            'mobile'
        ];
    }

    /**
     * @return array
     */
    public function getColumnsForLikeMatch(): array {
         return [
            'username'
        ];
    }

    /**
     * @return array
     */
    public function getColumnsForBooleanMatch(): array {
         return [
            'is_active'
        ];
    }

    /**
     * @return array
     */
    public function getColumnsForPeriodMatch(): array
    {
        return [
            'logged_in'
        ];
    }
}
```

Search
------

[](#search)

With the models prepared you can search them like this:

```
class UserController extends Controller
{

    /**
     * @return JsonResponse
     */
    public function index(): JsonResponse
    {
        $users = new Search(Request()->toArray(), User::query())->get();
        return response()->json([
            'users' => $users
        ]);
    }
}
```

You can easily search from the users' list by calling the below link:

```
{{address}}/users?username=hanie?mobile=?is_active=1?logged_in_from=2023-10-10?logged_in_to=2023-12-10

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

903d ago

### Community

Maintainers

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

---

Top Contributors

[![hanieas](https://avatars.githubusercontent.com/u/26707806?v=4)](https://github.com/hanieas "hanieas (8 commits)")

---

Tags

databaselaravelphpsearch

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hanieas-larasearch/health.svg)

```
[![Health](https://phpackages.com/badges/hanieas-larasearch/health.svg)](https://phpackages.com/packages/hanieas-larasearch)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[matanyadaev/laravel-eloquent-spatial

Spatial library for Laravel

3982.9M15](/packages/matanyadaev-laravel-eloquent-spatial)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

240173.5k2](/packages/dragon-code-laravel-deploy-operations)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

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