bipinkareparambil/laravel-where-like-any

Adds whereLikeAny, whereLikeAll, whereNotLikeAny, whereNotLikeAll (and or* variants) to Laravel's query builder.

Maintainers

Package info

github.com/bipinks/laravel-where-like-any

pkg:composer/bipinkareparambil/laravel-where-like-any

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-04-17 10:03 UTC

This package is auto-updated.

Last update: 2026-04-17 10:07:33 UTC


README

Adds symmetric "one column, multiple patterns" LIKE filtering to Laravel's query builder, complementing the built-in whereAny / whereAll (which handle "multiple columns, one pattern").

Install

composer require bipinkareparambil/laravel-where-like-any

The service provider auto-registers. The new methods are available on Illuminate\Database\Query\Builder and, by extension, Eloquent builders.

Methods

Method SQL
whereLikeAny($col, $values) (col LIKE ? OR col LIKE ?)
whereNotLikeAny($col, $values) (col NOT LIKE ? AND col NOT LIKE ?)
whereLikeAll($col, $values) (col LIKE ? AND col LIKE ?)
whereNotLikeAll($col, $values) (col NOT LIKE ? OR col NOT LIKE ?)

Plus or variants: orWhereLikeAny, orWhereNotLikeAny, orWhereLikeAll, orWhereNotLikeAll.

All methods accept a $caseSensitive flag. Under the hood each call delegates to whereLike, so MySQL like binary, Postgres ilike, and SQLite glob all work automatically — no grammar changes.

Usage

// Match any pattern
User::whereLikeAny('name', ['%john%', '%jane%'])->get();

// Match all patterns
User::whereLikeAll('bio', ['%laravel%', '%php%'])->get();

// Exclude any pattern
User::whereNotLikeAny('email', ['%spam%', '%temp%'])->get();

// Case-sensitive on MySQL
User::whereLikeAny('name', ['%John%'], caseSensitive: true)->get();

Negation semantics (De Morgan's)

  • whereNotLikeAny negates "match any" → flips OR to AND.
  • whereNotLikeAll negates "match all" → flips AND to OR.

Tests

composer install
vendor/bin/phpunit

Why a package?

Originally proposed to Laravel core in laravel/framework#59725. Released as a package per maintainer preference to keep the core surface area small.

License

MIT