I have an array to perform a where statement:
$array = ['name' => 'Jhon', 'age' => '27'];
User::where($array);
I need to use the same array to perform a search between two different age, I need something like:
User::where('age', '>=', '28')->where('age' , '<=', 50);
How should I do that using the above array?
You can use the whereBetween method:
User::whereBetween('age', [28, 50]);
You can read more about what conditions you can use in the Where Clauses documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With