mounika @Bobelism
This may help. This is not the exact code. This code was for Store Owner.
$todayordersCountDisplay = Order::whereIn('restaurant_id', $restaurantIds)->whereDate('created_at', Carbon::now())
->where('orderstatus_id', '5')->get('id')->count();
$orderItemsCount_id = Order::whereIn('restaurant_id', $restaurantIds)->where('orderstatus_id', '5')->get('id');
$orderItemsCount = Orderitem::whereIn('order_id', $orderItemsCount_id)->get()->count();
$todayitemsCount_id = Order::whereIn('restaurant_id', $restaurantIds)->whereDate('created_at', Carbon::now())
->where('orderstatus_id', '5')->get('id');
$todayitemsCount = Orderitem::whereIn('order_id', $todayitemsCount_id)->get()->count();
$allCompletedOrders = Order::whereIn('restaurant_id', $restaurantIds)
->where('orderstatus_id', '5')
->get();
$allCompletedOrderstoday = Order::whereIn('restaurant_id', $restaurantIds)
->where('orderstatus_id', '5')->whereDate('created_at', Carbon::now())
->get();
$totalEarning = 0;
settype($var, 'float');
foreach ($allCompletedOrders as $completedOrder) {
$totalEarning += $completedOrder->total - ($completedOrder->delivery_charge + $completedOrder->tip_amount);
}
$totalEarningtoday = 0;
settype($var, 'float');
foreach ($allCompletedOrderstoday as $completedOrdertoday) {
$totalEarningtoday += $completedOrdertoday->total - ($completedOrdertoday->delivery_charge + $completedOrdertoday->tip_amount);
}