select_expr('MONTH(created_at)', 'month') ->select_expr('COUNT(*)', 'count') ->where_raw('YEAR(created_at) = YEAR(NOW())') ->group_by_expr('MONTH(created_at)') ->find_many(); $monthlyRegistered = []; foreach ($result as $row) { $monthlyRegistered[] = [ 'date' => $row->month, 'count' => $row->count ]; } file_put_contents($cacheMRfile, json_encode($monthlyRegistered)); } $ui->assign('monthlyRegistered', $monthlyRegistered); return $ui->fetch('widget/graph_monthly_registered_customers.tpl'); } }