@mufasaparadox if you look at Raw Expressions
The whereRaw and orWhereRaw methods can be used to inject a raw where clause into your query. These methods accept an optional array of bindings as their second argument:
the bindings should be an array
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
So far this is the MySQL query and it works perfectly. It filters records by matching passed value to TIME(fecha_hora):
select nombre_departamento, categoria_respuesta, count(valor_evaluacion) from
detalle_evaluaciones JOIN departamentos ON departamentos.id =
detalle_evaluaciones.departamentos_id JOIN tipo_respuestas ON tipo_respuestas.id = detalle_evaluaciones.tipo_respuestas_id
where TIME(fecha_hora) = '06:13:00'
group by nombre_departamento, categoria_respuesta ORDER BY `tipo_respuestas`.`id` desc
This is what I have tried in laravel:
$hora = $request->get('hora');
$hora1 = date('H:i:s', strtotime("$hora"));
$calif = DB::table ('detalle_evaluaciones')->select (DB::raw('departamentos.nombre_departamento,tipo_respuestas.categoria_respuesta, detalle_evaluaciones.valor_evaluacion, COUNT(detalle_evaluaciones.valor_evaluacion) as cantidad'))
->join ('departamentos','detalle_evaluaciones.departamentos_id','=','departamentos.id')
->join ('tipo_respuestas','detalle_evaluaciones.tipo_respuestas_id','=','tipo_respuestas.id')
->whereRaw('(TIME(detalle_evaluaciones.fecha_hora)=?)',$hora1)
->groupby ('departamentos.nombre_departamento','tipo_respuestas.categoria_respuesta')
->orderby ('tipo_respuestas.id','DESC')
->paginate(10);
$calif will save all query data and return it and $hora1 is getting input time and passing its value to query builder where clause. It is not working at all. fecha_hora is of datetime type and it has both the date and time.
How to achieve this?
It's the same. I just usually link to the current version. Just use the version changer in the docs (upper-right corner) and select 5.5.
Please or to participate in this conversation.