Please post your code correctly, please see
https://laracasts.com/discuss/channels/general-discussion/guidelines-for-posting-on-laracastscom
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
So i make this query
$mainData = DB::table('table')
->where('id', $id)
->where('param1', '>', 0)
->where('param2', '>', 0)
->orderBy('param1', 'DESC')
->where('param1', '>=', DB::raw('UNIX_TIMESTAMP((LAST_DAY(DATE_SUB(NOW(), INTERVAL ' . intval($month) . ' MONTH))+INTERVAL 1 DAY)-INTERVAL 1 MONTH)'))
->where('param1', '<', DB::raw('UNIX_TIMESTAMP(LAST_DAY(DATE_SUB(NOW(), INTERVAL ' . intval($month) . ' MONTH))+INTERVAL 1 DAY)'))
->get();
and when i call before this function time() and after dd(time()-$start); i see 3second cuz when i run this query in phpmyadmin(i get query by toSql()) and Query took 0.0015 seconds. cuz why eloquent is so slow?
Please or to participate in this conversation.