Level 53
Just about the same as any other SQL Query:
$numToFind = 500;
if(Model::where('range_from', '>=', $numToFind)->where('range_to', '<=', $numToFind)->count()) {
// It exists...
}
For example, my database structure is:
+------------+----------+
| Range from | Range To |
+------------+----------+
| 100 | 200 |
| 220 | 250 |
| 500 | 600 |
| 620 | 700 |
+------------+----------+
I need to check the existence of number 500. That should return true because there is a row 500-600. Also 660 should return true because there is a row 620-700.
How can I query this with Eloquent efficiently? Sort of between with dates.
Thnx in advance.
Please or to participate in this conversation.