I'm trying to use Eloquent to query a table of records in the database and only retrieve those records where at least 1 record in a json column, consisting of an array of objects, is within a given date range.
The dates column would look as follows:
[
{'date': '2021-01-01'},
{'date': '2021-01-02'},
{'date': '2021-01-03'},
]
If I pass a start date of '2021-01-01' it then needs to fetch all records where dates.*.date is equal to or after this start date.
The same applies to the an end_date.
I've different kinds of syntax like:
$this->where('dates->[*]->date', '<=', date($value));
$this->where('dates->*->date', '<=', date($value));
$this->where('dates.*.date', '<=', date($value));
Nothing seems to work.
What am I doing wrong?