Upon adding the following where condition :
->whereBetween('p.created_at', [ Carbon::parse('c.created_at')->format('Y-m-d 00:00:00'), Carbon::now()->endOfDay()])
I receive this error :
DateTime::__construct(): Failed to parse time string (c.created_at) at position 8 (d): Double timezone specification
Advertisement
Answer
I guess your c.created_at
is a column from a joined table in your query.. where between expects the second parameter to be an array of objects, but c.created_at
cannot be included just like that there..
You will have to do a full query in order to select that column only.. or just use a raw query like this:
->whereRaw('p.created_at between c.created_at and ?', [ now()->endOfDay() ])