Laravel this is not only a practical framework, it is also a programming style. ... MySQL SELECT COUNT with multiple conditions I have an issue when running this query : I have a self-made visitor counter (sort of) I'm using the pragmarx plugin, but getting the data by myself. So I have a chart, wich looks like this: When I count everything from the day, there is no problem, it returns the correct values. But when I try to get the count of visits of each week, month... Laravel db raw where clause example If you need to use sql aggregate function with where clause in laravel query builder then you can do it using db raw or whereraw function of laravel eloquent. here you will learn how to use db raw with where clause.