customer report

This commit is contained in:
omair saleh
2021-10-02 15:15:27 +08:00
parent 95f52b3a62
commit c74e2927ad
@@ -6,13 +6,15 @@ use App\Classes\ValueObjects\Constants\HttpStatus;
use App\Classes\ValueObjects\Response\ApiResponseObject;
use App\Models\Container;
use App\Models\Order;
use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class MonthlyReportController
{
public function report(Request $request): JsonResponse {
$containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->orderBy('loading_date')->get();
$month = Carbon::now()->subMonth();
$containers = Container::whereMonth('loading_date', $month->format('m'))->whereYear('loading_date', '=', '2021')->orderBy('loading_date')->get();
$total = 0;
$customers = collect();
@@ -56,7 +58,7 @@ class MonthlyReportController
'packages' => $customers->sum(function($customer){
return $customer['packages'];
}),
'total_orders' => Order::whereMonth('created_at', 9)->whereHas('packingLists')->count()
'total_orders' => Order::whereMonth('created_at', $month->format('m'))->count()
]]))->handler();
}
}