Skip to content
Advertisement

changing sql statement to eloquent query

So I have an SQL statement as such;

AND created_at BETWEEN '20190601' and '20190630'

How do I change this to an eloquent query? Or is it better to just use a db:raw query?

All inputs are very much appreciated. Cheers!

Advertisement

Answer

You can try this :

$yourQuery->whereBetween('created_at', ['20190601', '20190630']);

Read more at whereBetween section in here

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement