Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

petrit's avatar
Level 20

Raw query eloquent

I have two time columns on a table, timeFrom and timeTo, and I am trying to get all rows where current time is between timeFrom and timeTo using this query which is working

$query->whereRaw('curtime() between timeFrom and timeTo');

I was wondering if there is a better way not using whereRaw on query because of sql injection!

0 likes
1 reply
Parasoul's avatar

You don't pass any data you could get from an user and laravel have a protection against injection. Noway this whereRaw cause an sql injection.

Please or to participate in this conversation.