The most common way is to chain the queries..
$articles = \App\Article::where('foo', 'bar')
->where('color', 'blue')
->orWhere('name', 'like', '%John%')
->whereIn('id', [1, 2, 3, 4, 5])
->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How do I write where with multiple conditions? I have the latest Laravel 5.3 and I have tried this and it won't work:
$articles = \App\Article::where(['title', 'like', '%' . $data['title']] . '%'],['published_at', '=', $data['published_at']],['OR'])->orderBy('id')->paginate(10);
I'm new to Laravel, so any advice if I'm not writing this incorrectly is really appreciated.
The most common way is to chain the queries..
$articles = \App\Article::where('foo', 'bar')
->where('color', 'blue')
->orWhere('name', 'like', '%John%')
->whereIn('id', [1, 2, 3, 4, 5])
->get();
Please or to participate in this conversation.