$search = '%Otwell%';
User::query()
->where(function ($query) use ($search) {
$query
->where('first_name', 'LIKE', $search)
->orWhere('last_name', 'LIKE', $search)
->orWhere('email', 'LIKE', $search)
->orWhere('phone', 'LIKE', $search);
})
...
whereAll
Parametreler:
whereAll($columns, $operator = null, $value = null, $boolean = 'and')
Kullanımı:
$search = 'test';
User::whereAll([
'first_name',
'last_name',
'email',
], 'LIKE', "%$search%")
...
SQL Çıktısı:
SELECT * FROM "users" WHERE (
"first_name" LIKE "%test%"
AND "last_name" LIKE "%test%"
AND "email" LIKE "%test%"
)
whereAny
Parametreler:
whereAll($columns, $operator = null, $value = null, $boolean = 'and')
Kullanımı:
$search = 'test';
User::whereAny([
'first_name',
'last_name',
'email',
], 'LIKE', "%$search%")
...
SQL Çıktısı:
SELECT * FROM "users" WHERE (
"first_name" LIKE "%test%"
OR "last_name" LIKE "%test%"
OR "email" LIKE "%test%"
)
Kaynaklar:
Github:
[10.x] Add whereAll and whereAny methods to the query builder - https://github.com/laravel/framework/pull/50344
Youtube:
New in Laravel 10.47: Eloquent whereAll() and whereAny() - https://www.youtube.com/watch?v=3DHPfgqMD04
Query Builder whereAll() and whereAny() Methods Added to Laravel 10.47 - https://laravel-news.com/laravel-10-47-0