From 0b7b22ff87d0bb8e58441c4fda5c9abebc701a28 Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sun, 14 Jun 2026 10:05:13 +0330 Subject: [PATCH] fix the command --- .../Commands/EncodePolyLineCommand.php | 3 ++- .../Report/ReportMachineController.php | 24 ++++++++++++++++++- .../V3/Mission/Violation/UpdateRequest.php | 14 +++++++++++ .../Mission/RequestPortalService.php | 1 + routes/v3.php | 2 ++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/EncodePolyLineCommand.php b/app/Console/Commands/EncodePolyLineCommand.php index 4dd32435..8fa34cd9 100644 --- a/app/Console/Commands/EncodePolyLineCommand.php +++ b/app/Console/Commands/EncodePolyLineCommand.php @@ -28,7 +28,8 @@ class EncodePolyLineCommand extends Command public function handle(PolylineEncoder $polylineEncoder): void { Mission::query()->whereNotNull('area')->each(function ($mission) use ($polylineEncoder) { - $encodedValue = $polylineEncoder->encodePolyLine($mission, lng_lat_format:true); + $area = json_decode($mission->area, true); + $encodedValue = $polylineEncoder->encodePolyLine($area['coordinates'], lng_lat_format:true); $mission->update([ 'encoded_route' => $encodedValue, ]); diff --git a/app/Http/Controllers/V3/Dashboard/Mission/Report/ReportMachineController.php b/app/Http/Controllers/V3/Dashboard/Mission/Report/ReportMachineController.php index e9d1e5c2..478f10e4 100644 --- a/app/Http/Controllers/V3/Dashboard/Mission/Report/ReportMachineController.php +++ b/app/Http/Controllers/V3/Dashboard/Mission/Report/ReportMachineController.php @@ -109,7 +109,7 @@ class ReportMachineController extends Controller allowedSortings: ['*'], allowedSelects: [ 'id', 'province_id', 'province_name', 'city_id', 'city_name', - 'end_km', 'km', 'driver_name', 'state_name', 'station_name' + 'end_km', 'km', 'driver_name', 'state_id', 'station_name' ] ); } @@ -125,4 +125,26 @@ class ReportMachineController extends Controller return Excel::download(new machineReport($data), $name); } + + public function countryMachineDriversActivity(Request $request, ReportMachineService $reportMachineService) + { + return $this->successResponse([ + 'activities' => $reportMachineService->countryMachineDriversActivity($request), +// 'provinces' => Province::all(['id', 'name_fa']), + ]); + } + + public function provinceMachineDriversActivity(Request $request, ReportMachineService $reportMachineService) + { + return $this->successResponse([ + 'activities' => $reportMachineService->provinceMachineDriversActivity($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']) + ]); + } } diff --git a/app/Http/Requests/V3/Mission/Violation/UpdateRequest.php b/app/Http/Requests/V3/Mission/Violation/UpdateRequest.php index 0948924e..f2e6b14e 100644 --- a/app/Http/Requests/V3/Mission/Violation/UpdateRequest.php +++ b/app/Http/Requests/V3/Mission/Violation/UpdateRequest.php @@ -29,4 +29,18 @@ class UpdateRequest extends FormRequest 'enter_station' => 'required|date', ]; } + + public function after(): array + { + return [ + function (Validator $validator) { + if (strtotime($this->violation->exit_station) < strtotime($this->enter_station)) { + $validator->errors()->add( + 'time', + 'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.' + ); + } + } + ]; + } } diff --git a/app/Services/Cartables/Mission/RequestPortalService.php b/app/Services/Cartables/Mission/RequestPortalService.php index 58d197b9..2c17793c 100644 --- a/app/Services/Cartables/Mission/RequestPortalService.php +++ b/app/Services/Cartables/Mission/RequestPortalService.php @@ -34,6 +34,7 @@ class RequestPortalService 'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id', 'end_date', 'request_date', 'end_point', 'encoded_route', 'zone', 'zone_fa', 'start_time', 'finish_time', 'code', 'category_id', 'category_name', 'explanation', 'city_id', 'city_name', 'province_id', 'station_name', + 'driver_id', 'driver_name' ] ); } diff --git a/routes/v3.php b/routes/v3.php index d4c2ef71..e94c6941 100644 --- a/routes/v3.php +++ b/routes/v3.php @@ -573,6 +573,8 @@ Route::prefix('missions') Route::get('/country_machine_types_activity', 'countryMachineTypesActivity')->name('countryMachineTypesActivity'); Route::get('/province_machine_types_activity', 'provinceMachineTypesActivity')->name('provinceMachineTypesActivity'); Route::get('/machine_details_report', 'machineDetailsReport')->name('machineDetailsReport'); + Route::get('/country_machine_drivers_activity', 'countryMachineDriversActivity')->name('countryMachineDriversActivity'); + Route::get('/province_machine_drivers_activity', 'provinceMachineDriversActivity')->name('provinceMachineDriversActivity'); }); }); -- 2.49.1