add report for machines

This commit is contained in:
2026-06-10 11:16:08 +03:30
parent a8b99706d0
commit 6b81075e40
10 changed files with 226 additions and 213 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\V3\Dashboard\Mission\Report;
use App\Exports\V3\Mission\Report\Machine\machineReport;
use App\Http\Controllers\Controller;
use App\Http\Traits\ApiResponse;
use App\Models\City;
use App\Models\Province;
use App\Services\Cartables\Mission\Report\ReportMachineService;
use Illuminate\Http\JsonResponse;
@@ -17,11 +18,11 @@ class ReportMachineController extends Controller
{
use ApiResponse;
public function activity(Request $request, ReportMachineService $reportMachineService): JsonResponse
public function countryMachinesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
{
return $this->successResponse([
'activities' => $reportMachineService->activity($request),
'provinces' => Province::all(['id', 'name_fa']),
'activities' => $reportMachineService->countryMachinesActivity($request),
// 'provinces' => Province::all(['id', 'name_fa']),
]);
}
@@ -29,12 +30,59 @@ class ReportMachineController extends Controller
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function excelActivity(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
public function countryMachinesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
{
$data = $reportMachineService->activity($request);
$name = 'گزارش کل تردد یک ماشین '.verta()->now()->format('Y-m-d H-i').'.xlsx';
$data = $reportMachineService->countryMachinesActivity($request);
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(new machineReport($data), $name);
}
public function provinceMachinesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
{
return $this->successResponse([
'activities' => $reportMachineService->countryMachinesActivity($request),
// 'city' => City::query()
// ->where('province_id', $request->province_id)
// ->where(function ($query) {
// $query->where('type_id', 1)
// ->orWhereIn('name_fa', ['اداره ماشين‌آلات', 'اداره نقلیه']);
// })
// ->get(['id', 'name_fa'])
]);
}
/**
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function provinceMachinesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
{
$data = $reportMachineService->countryMachinesActivity($request);
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
return Excel::download(new machineReport($data), $name);
}
public function countryMachineTypesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
{
return $this->successResponse([
'activities' => $reportMachineService->countryMachineTypesActivity($request),
// 'provinces' => Province::all(['id', 'name_fa']),
]);
}
public function provinceMachineTypesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
{
return $this->successResponse([
'activities' => $reportMachineService->provinceMachineTypesActivity($request),
// 'city' => City::query()
// ->where('province_id', $request->province_id)
// ->where(function ($query) {
// $query->where('type_id', 1)
// ->orWhereIn('name_fa', ['اداره ماشين‌آلات', 'اداره نقلیه']);
// })
// ->get(['id', 'name_fa'])
]);
}
}