subMonth()->startOfDay(); $endDate = (new DateTime())->endOfDay(); $counts = Product::query()->selectRaw(" COUNT(*) as total_products ") ->whereNotIn('post_status', ['trash', 'auto-draft']) ->first(); $sales = App::db()->table('fct_orders as o')->selectRaw(" COUNT(o.id) AS orders, SUM( o.total_paid - o.total_refund - o.tax_total - o.shipping_tax ) / 100 AS net_revenue, SUM(o.total_refund) / 100 AS total_refunds ") ->whereBetween('o.created_at', [$startDate, $endDate]) ->whereNotIn('o.status', [Status::ORDER_ON_HOLD, Status::ORDER_FAILED]) ->first(); return [ [ 'title' => __('Total Products', 'fluent-cart'), 'current_count' => $counts->total_products, 'icon' => 'Frame', 'url' => URL::getDashboardUrl('products', [ 'active_view' => 'all', ]), ], [ 'title' => __('Orders', 'fluent-cart'), 'current_count' => $sales->orders, 'icon' => 'AllOrdersIcon', 'url' => URL::getDashboardUrl('orders'), ], [ 'title' => __('Revenue', 'fluent-cart'), 'current_count' => $sales->net_revenue, 'icon' => 'Currency', 'url' => URL::getDashboardUrl('reports/revenue'), 'has_currency' => true, ], [ 'title' => __('Refund', 'fluent-cart'), 'current_count' => $sales->total_refunds, 'icon' => 'Failed', 'url' => URL::getDashboardUrl('reports/refunds'), 'has_currency' => true, ], ]; } }