mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-24 06:54:26 +00:00
customer report
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user