change structure of road patrol and route

This commit is contained in:
2025-06-16 14:40:01 +03:30
parent d16effc80e
commit a5e5365177
4 changed files with 388 additions and 36 deletions

View File

@@ -3,12 +3,14 @@
namespace App\Http\Controllers\V3\RoadPatrole;
use App\Exports\V3\RoadPatrols\CountryActivity;
use App\Exports\V3\RoadPatrols\SupervisorCartableReport;
use App\Http\Controllers\Controller;
use App\Http\Traits\ApiResponse;
use App\Models\Province;
use App\Services\Cartables\RoadPatrolTableService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Maatwebsite\Excel\Facades\Excel;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
@@ -38,6 +40,26 @@ class SupervisorController extends Controller
'provinces' => $provinces,
]), $name);
}
public function supervisorIndex(Request $request, RoadPatrolTableService $roadPatrolTableService): JsonResponse
{
$data = $roadPatrolTableService->supervisorCartableReport($request);
foreach ($data['data'] as $road_patrol) {
if (Gate::allows('gate-supervise-road-item', $road_patrol)) {
$road_patrol['can_supervise'] = 1;
} else {
$road_patrol['can_supervise'] = 0;
}
}
return response()->json($data);
}
public function supervisorCartableReport(Request $request, RoadPatrolTableService $roadPatrolTableService): BinaryFileResponse
{
$name = 'گزارش از کارتابل ارزیابی گشت راهداری ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
$data = $roadPatrolTableService->supervisorCartableReport($request, true);
return Excel::download(new SupervisorCartableReport($data['data']), $name);
}