bipinkareparambil/laravel-where-like-any
最新稳定版本:v1.0.0
Composer 安装命令:
composer require bipinkareparambil/laravel-where-like-any
包简介
Adds whereLikeAny, whereLikeAll, whereNotLikeAny, whereNotLikeAll (and or* variants) to Laravel's query builder.
README 文档
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)
whereNotLikeAnynegates "match any" → flipsORtoAND.whereNotLikeAllnegates "match all" → flipsANDtoOR.
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
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-17