From 294f89b4adc72063306c3f77cc9a931f57eba2b6 Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sat, 4 Jan 2025 13:14:14 +0330 Subject: [PATCH] create a rule to verify otp --- .../V3/FMSVehicleManagementController.php | 1 - .../V3/RoadPatrolProjectController.php | 15 +---------- .../V3/RoadPatrolProject/StoreRequest.php | 7 ++--- app/Rules/VerificationCode.php | 27 +++++++++++++++++++ .../FMS/GetVehicleActivityService.php | 1 + 5 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 app/Rules/VerificationCode.php diff --git a/app/Http/Controllers/V3/FMSVehicleManagementController.php b/app/Http/Controllers/V3/FMSVehicleManagementController.php index f50221a7..898ede9d 100644 --- a/app/Http/Controllers/V3/FMSVehicleManagementController.php +++ b/app/Http/Controllers/V3/FMSVehicleManagementController.php @@ -22,7 +22,6 @@ class FMSVehicleManagementController extends Controller "machineCode" => $request->machineCode, "startDT" => $request->startDT, "endDT" => $request->endDT, - "minStopDuration" => $request->minStopDuration ]); $data = $getVehicleActivityService->run(); diff --git a/app/Http/Controllers/V3/RoadPatrolProjectController.php b/app/Http/Controllers/V3/RoadPatrolProjectController.php index 4e2fbded..27f84c65 100644 --- a/app/Http/Controllers/V3/RoadPatrolProjectController.php +++ b/app/Http/Controllers/V3/RoadPatrolProjectController.php @@ -161,24 +161,13 @@ class RoadPatrolProjectController extends Controller ], 400); } - $start_coordinates = explode(',', $request->start_point); - $end_coordinates = explode(',', $request->end_point); - $edare_id = $user->edarate_shahri_id ?? $user->edarate_ostani_id; $edare_name = $user->edarate_shahri_id ? $user->edarate_shahri_name : $user->edarate_ostani_name; - $road_patrol = DB::transaction(function () use ($request, $start_coordinates, - $end_coordinates, $edare_id, + $road_patrol = DB::transaction(function () use ($request, $edare_id, $edare_name, $nominatimService, $user) { $road_patrol = RoadPatrol::query()->create([ - 'start_lat' => $start_coordinates[0], - 'start_lon' => $start_coordinates[1], - 'end_lat' => $end_coordinates[0], - 'end_lon' => $end_coordinates[1], - 'officer_name' => $request->officer_name, - 'officer_phone_number' => $request->officer_phone_number, - 'officer_plaque' => $request->officer_plaque, 'operator_id' => $user->id, 'operator_name' => $user->name, 'province_id' => $user->province_id, @@ -187,8 +176,6 @@ class RoadPatrolProjectController extends Controller 'city_fa' => $user->city_fa, 'edare_id' => $edare_id, 'edare_name' => $edare_name, - 'start_way_id' => $nominatimService->get_way_id_from_nominatim($start_coordinates[0], $start_coordinates[1]), - 'end_way_id' => $nominatimService->get_way_id_from_nominatim($end_coordinates[0], $end_coordinates[1]), 'status' => 0, 'status_fa' => 'در حال بررسی', 'distance' => $request->distance, diff --git a/app/Http/Requests/V3/RoadPatrolProject/StoreRequest.php b/app/Http/Requests/V3/RoadPatrolProject/StoreRequest.php index 353a814c..b0986e4b 100644 --- a/app/Http/Requests/V3/RoadPatrolProject/StoreRequest.php +++ b/app/Http/Requests/V3/RoadPatrolProject/StoreRequest.php @@ -2,6 +2,7 @@ namespace App\Http\Requests\V3\RoadPatrolProject; +use App\Rules\VerificationCode; use Illuminate\Foundation\Http\FormRequest; class StoreRequest extends FormRequest @@ -22,12 +23,8 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'start_point' => 'required', - 'end_point' => 'required', + 'verification_code' => ['required', 'string', new VerificationCode($this->phone_number)], 'distance' => 'numeric', - 'officer_name' => 'required', - 'officer_plaque' => 'required', - 'officer_phone_number' => 'required|digits:11', 'start_time' => 'required|date_format:Y-m-d H:i', 'end_time' => 'required|date_format:Y-m-d H:i|after:start_time', 'fuel_consumption' => 'required|integer', diff --git a/app/Rules/VerificationCode.php b/app/Rules/VerificationCode.php new file mode 100644 index 00000000..fedeb0c5 --- /dev/null +++ b/app/Rules/VerificationCode.php @@ -0,0 +1,27 @@ +phone_number, $value); + + if (!$verified) { + $fail('The :attribute is not valid.')->translate(); + } + } +} diff --git a/app/Services/FMS/GetVehicleActivityService.php b/app/Services/FMS/GetVehicleActivityService.php index 94f124eb..e7b6dd28 100644 --- a/app/Services/FMS/GetVehicleActivityService.php +++ b/app/Services/FMS/GetVehicleActivityService.php @@ -63,6 +63,7 @@ class GetVehicleActivityService $inputData = $this->inputParameters + array( "username" => $this->username, "password" => $this->password, + "minStopDuration" => 1, ); return json_encode($inputData);