create a rule to verify otp
This commit is contained in:
@@ -22,7 +22,6 @@ class FMSVehicleManagementController extends Controller
|
|||||||
"machineCode" => $request->machineCode,
|
"machineCode" => $request->machineCode,
|
||||||
"startDT" => $request->startDT,
|
"startDT" => $request->startDT,
|
||||||
"endDT" => $request->endDT,
|
"endDT" => $request->endDT,
|
||||||
"minStopDuration" => $request->minStopDuration
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$data = $getVehicleActivityService->run();
|
$data = $getVehicleActivityService->run();
|
||||||
|
|||||||
@@ -161,24 +161,13 @@ class RoadPatrolProjectController extends Controller
|
|||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$start_coordinates = explode(',', $request->start_point);
|
|
||||||
$end_coordinates = explode(',', $request->end_point);
|
|
||||||
|
|
||||||
$edare_id = $user->edarate_shahri_id ?? $user->edarate_ostani_id;
|
$edare_id = $user->edarate_shahri_id ?? $user->edarate_ostani_id;
|
||||||
$edare_name = $user->edarate_shahri_id ? $user->edarate_shahri_name : $user->edarate_ostani_name;
|
$edare_name = $user->edarate_shahri_id ? $user->edarate_shahri_name : $user->edarate_ostani_name;
|
||||||
|
|
||||||
$road_patrol = DB::transaction(function () use ($request, $start_coordinates,
|
$road_patrol = DB::transaction(function () use ($request, $edare_id,
|
||||||
$end_coordinates, $edare_id,
|
|
||||||
$edare_name, $nominatimService, $user) {
|
$edare_name, $nominatimService, $user) {
|
||||||
|
|
||||||
$road_patrol = RoadPatrol::query()->create([
|
$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_id' => $user->id,
|
||||||
'operator_name' => $user->name,
|
'operator_name' => $user->name,
|
||||||
'province_id' => $user->province_id,
|
'province_id' => $user->province_id,
|
||||||
@@ -187,8 +176,6 @@ class RoadPatrolProjectController extends Controller
|
|||||||
'city_fa' => $user->city_fa,
|
'city_fa' => $user->city_fa,
|
||||||
'edare_id' => $edare_id,
|
'edare_id' => $edare_id,
|
||||||
'edare_name' => $edare_name,
|
'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' => 0,
|
||||||
'status_fa' => 'در حال بررسی',
|
'status_fa' => 'در حال بررسی',
|
||||||
'distance' => $request->distance,
|
'distance' => $request->distance,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Requests\V3\RoadPatrolProject;
|
namespace App\Http\Requests\V3\RoadPatrolProject;
|
||||||
|
|
||||||
|
use App\Rules\VerificationCode;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class StoreRequest extends FormRequest
|
class StoreRequest extends FormRequest
|
||||||
@@ -22,12 +23,8 @@ class StoreRequest extends FormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'start_point' => 'required',
|
'verification_code' => ['required', 'string', new VerificationCode($this->phone_number)],
|
||||||
'end_point' => 'required',
|
|
||||||
'distance' => 'numeric',
|
'distance' => 'numeric',
|
||||||
'officer_name' => 'required',
|
|
||||||
'officer_plaque' => 'required',
|
|
||||||
'officer_phone_number' => 'required|digits:11',
|
|
||||||
'start_time' => 'required|date_format:Y-m-d H:i',
|
'start_time' => 'required|date_format:Y-m-d H:i',
|
||||||
'end_time' => 'required|date_format:Y-m-d H:i|after:start_time',
|
'end_time' => 'required|date_format:Y-m-d H:i|after:start_time',
|
||||||
'fuel_consumption' => 'required|integer',
|
'fuel_consumption' => 'required|integer',
|
||||||
|
|||||||
27
app/Rules/VerificationCode.php
Normal file
27
app/Rules/VerificationCode.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Rules;
|
||||||
|
|
||||||
|
use App\Facades\Otp\Otp;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Translation\PotentiallyTranslatedString;
|
||||||
|
|
||||||
|
class VerificationCode implements ValidationRule
|
||||||
|
{
|
||||||
|
public function __construct(protected string $phone_number){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the validation rule.
|
||||||
|
*
|
||||||
|
* @param \Closure(string): PotentiallyTranslatedString $fail
|
||||||
|
*/
|
||||||
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||||
|
{
|
||||||
|
$verified = Otp::verifyOtpToken($this->phone_number, $value);
|
||||||
|
|
||||||
|
if (!$verified) {
|
||||||
|
$fail('The :attribute is not valid.')->translate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,6 +63,7 @@ class GetVehicleActivityService
|
|||||||
$inputData = $this->inputParameters + array(
|
$inputData = $this->inputParameters + array(
|
||||||
"username" => $this->username,
|
"username" => $this->username,
|
||||||
"password" => $this->password,
|
"password" => $this->password,
|
||||||
|
"minStopDuration" => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
return json_encode($inputData);
|
return json_encode($inputData);
|
||||||
|
|||||||
Reference in New Issue
Block a user