PHPackages                             diarsa/laravel-where-like - 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. diarsa/laravel-where-like

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

diarsa/laravel-where-like
=========================

A Laravel package that simplifies searching across multiple fields, including related models, using Laravel's query builder in an efficient way.

v1.1.3(6mo ago)167MITPHPPHP ^8.1|^8.2|^8.3|^8.4CI passing

Since Oct 11Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/diarsa/laravel-where-like)[ Packagist](https://packagist.org/packages/diarsa/laravel-where-like)[ Docs](https://github.com/diarsa/laravel-where-like)[ GitHub Sponsors](https://github.com/diarsa)[ RSS](/packages/diarsa-laravel-where-like/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (7)Versions (6)Used By (0)

A Laravel package that provides an easy way to use query builder
================================================================

[](#a-laravel-package-that-provides-an-easy-way-to-use-query-builder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a1b36dc07e3715dcb08b4859393699cae5ac22bf6ddcd6c26c5f26d88882879c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6469617273612f6c61726176656c2d77686572652d6c696b652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/diarsa/laravel-where-like)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ccc36113959651cf445a9db6bcac0091a4fe70e6af9a42c753e37d15f866301f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6469617273612f6c61726176656c2d77686572652d6c696b652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/diarsa/laravel-where-like/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/d3b08c92aaa29d0138d180c084c78d4175fbd4c4342fd5c92f802df80cbb4707/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6469617273612f6c61726176656c2d77686572652d6c696b652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/diarsa/laravel-where-like/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/4c57e5a17225efc70e4459195ddd355b03d5de92e98daf5dd91df0b48aa2487a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6469617273612f6c61726176656c2d77686572652d6c696b652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/diarsa/laravel-where-like)

Search using Laravel's query builder across multiple fields, including related models, in a simple and efficient way.

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

[](#installation)

You can install the package via composer:

```
composer require diarsa/laravel-where-like
```

Usage
-----

[](#usage)

### Without whereLike (Traditional Way)

[](#without-wherelike-traditional-way)

Without this package, you would need to write complex queries with multiple `orWhere` and `orWhereHas` clauses:

```
$search = $request->search;
return User::where('status', 1)
    ->where(function ($query) use ($search) {
        $query->where('name', 'LIKE', "%{$search}%")
              ->orWhere('address', 'LIKE', "%{$search}%")
              ->orWhereHas('categoryDetail', function ($query) use ($search) {
                  $query->where('category_code', 'LIKE', "%{$search}%");
              })
              ->orWhereHas('histories', function ($query) use ($search) {
                  $query->where('device', 'LIKE', "%{$search}%");
              });
    })
    ->get();
```

### With whereLike (Simplified Way)

[](#with-wherelike-simplified-way)

With this package, you can perform searches across multiple fields, including related models, using this simple method:

```
$search = $request->search;
return User::where('status', 1)
    ->whereLike(
        ['name', 'address', 'categoryDetail.category_code', 'histories.device'],
        $search
    )
    ->get();
```

### More Examples

[](#more-examples)

#### Searching in Multiple Fields

[](#searching-in-multiple-fields)

```
// Search in user's basic fields
User::whereLike(['name', 'email', 'phone'], $searchTerm)->get();
```

#### Searching in Related Models

[](#searching-in-related-models)

```
// Search in user and their profile information
User::whereLike([
    'name',
    'email',
    'profile.bio',
    'profile.location',
    'posts.title',
    'posts.content'
], $searchTerm)->get();
```

#### Searching with Additional Conditions

[](#searching-with-additional-conditions)

```
// Combine with other query conditions
User::where('status', 'active')
    ->where('created_at', '>=', now()->subMonth())
    ->whereLike(['name', 'email', 'profile.bio'], $searchTerm)
    ->orderBy('created_at', 'desc')
    ->paginate(10);
```

### Additional Features

[](#additional-features)

#### Mask Sensitive Data

[](#mask-sensitive-data)

The package also provides a `maskSensitiveData` macro for Laravel Collections to help you mask sensitive information:

```
use Illuminate\Support\Collection;

$sensitiveData = collect(['john.doe@email.com', '081234567890', 'SecretPassword123']);

// Default masking (shows first 2 and last 2 characters)
$masked = $sensitiveData->map(function ($item) {
    return collect()->maskSensitiveData($item);
});
// Result: ['jo***@email.com', '08******7890', 'Se**********123']

// Custom masking (first 3 and last 1 characters)
$customMasked = $sensitiveData->map(function ($item) {
    return collect()->maskSensitiveData($item, 3, 1);
});
// Result: ['joh******.com', '083*******0', 'Sec**********3']
```

Requirements
------------

[](#requirements)

- PHP 8.1, 8.2, 8.3, or 8.4
- Laravel 9.x, 10.x, 11.x, or 12.x

Another methods.

```
$laravelWhereLike = new Diarsa\LaravelWhereLike\LaravelWhereLike();
echo $laravelWhereLike->tambah(1, 4);

use Diarsa\LaravelWhereLike\LaravelWhereLike;
Route::get('calculate', function() {
    return LaravelWhereLike::tambah(1, 4);
});
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Support us
----------

[](#support-us)

You can support us by [Buy me a coffee](https://buymeacoffee.com/diarsa).

Credits
-------

[](#credits)

- [Bayu Diarsa](https://github.com/diarsa)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance65

Regular maintenance activity

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Every ~92 days

Total

5

Last Release

209d ago

PHP version history (3 changes)v1.0PHP ^8.2

v1.1.2PHP ^8.2|^8.3|^8.4

v1.1.3PHP ^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

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

---

Top Contributors

[![diarsa](https://avatars.githubusercontent.com/u/19700154?v=4)](https://github.com/diarsa "diarsa (36 commits)")

---

Tags

searchlaraveleloquentquery builderdiarsalaravel-where-like

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/diarsa-laravel-where-like/health.svg)

```
[![Health](https://phpackages.com/badges/diarsa-laravel-where-like/health.svg)](https://phpackages.com/packages/diarsa-laravel-where-like)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17649.9k](/packages/lacodix-laravel-model-filter)[giacomomasseron/laravel-models-generator

Generate Laravel models from an existing database

484.2k](/packages/giacomomasseron-laravel-models-generator)[mozex/laravel-scout-bulk-actions

A Laravel Scout extension for bulk importing and flushing of all models.

1033.4k](/packages/mozex-laravel-scout-bulk-actions)

PHPackages © 2026

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