Level 75
You can use whereIn.
This is just an example.
$users = DB::table('users')
->whereIn('id', [1, 2, 3])
->get();
You can find it in documentation https://laravel.com/docs/7.x/queries#where-clauses
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm getting multiple checkbox values as an array in my courseController.
I want to filter and search for courses so I want to search the database for each value stored in an array. How can I do this?
Can someone help me with this?
You can use whereIn.
This is just an example.
$users = DB::table('users')
->whereIn('id', [1, 2, 3])
->get();
You can find it in documentation https://laravel.com/docs/7.x/queries#where-clauses
Please or to participate in this conversation.