79959/how-to-make-laravel-eloquent-in-query
I want to make query in Laravel Eloquent like here its raw MySQL query
SELECT * from exampleTbl where id in(1,2,3,4)
I have tried this in Laravel Eloquent but it's not working
DB::where("id IN(23,25)")->get()
Hello @kartik,
Here is how you do in Eloquent
$users = User::whereIn('id', array(1, 2, 3))->get();
And if you are using Query builder then :
$users = DB::table('users')->whereIn('id', array(1, 2, 3))->get();
Hope it works!!
Thank You!!
Hii, You can create a constants.php page in config folder ...READ MORE
Hello @kartik, It's not really Eloquent, to add ...READ MORE
Hello @kartik, The code below solved my problem: $messages ...READ MORE
Hello @kartik, lists() turns the resulting collection into an ...READ MORE
Hey @kartik, First you have to go to ...READ MORE
Named route is used to give specific ...READ MORE
Hello, This is simple you just need to ...READ MORE
Hey @kartik, Named routing is another amazing feature of ...READ MORE
Hello @kartik, You can use less code, writing ...READ MORE
Hello, You can use simple function that is ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.