I have the following query params in string format
$query = '->whereIn('short_code', ["9999"])->whereBetween('request_timestamp', [request('startTime'), request('endTime')])';
How do i pass it to the eloquent? Am trying to achieve something like this
InboundMessage::query()->{$query};
Am getting the error below
Property [->whereIn('short_code', ["9999"])->whereBetween('request_timestamp', [request('startTime'), request('endTime')])] does not exist on the Eloquent builder instance.
2
Answers
The problem with the above query is that it looks like this
Since you have put
->
in both the query builder and the $query string. So just adjust your $query toIt will be something like this (not tested) using raw DB expressions: