diff --git a/app/Http/Controllers/V3/Dashboard/Harim/PanjareVahedController.php b/app/Http/Controllers/V3/Dashboard/Harim/PanjareVahedController.php index dbbb9128..9d5c065d 100644 --- a/app/Http/Controllers/V3/Dashboard/Harim/PanjareVahedController.php +++ b/app/Http/Controllers/V3/Dashboard/Harim/PanjareVahedController.php @@ -21,6 +21,13 @@ class PanjareVahedController extends Controller public function receiveNewRequest(ReceiveNewRequest $request): JsonResponse { + $iv = config('harim_web_services.Get_Info.iv'); + $keyString = config('harim_web_services.Get_Info.keyString'); + + $key = hash('sha256',$keyString, true); + + $decrypted = openssl_decrypt($request->data, 'aes-256-cbc', $key, false, $iv); + $wkt = 'POLYGON(('.implode(',', array_map(fn ($c) => "{$c[0]} {$c[1]}", $request->primary_area['coordinates'])).'))'; $result = DB::selectOne('SELECT ST_AsText(ST_PointOnSurface(ST_GeomFromText(?, 4326))) AS point', [$wkt]); preg_match('/POINT\(([^ ]+) ([^ ]+)\)/', $result->point, $matches); @@ -62,12 +69,11 @@ class PanjareVahedController extends Controller 'response_options' => json_encode($request->response_options), 'isic' => $request->isic, 'primary_area' => json_encode($request->primary_area), - 'data' => $request->data['data'], - 'token' => $request->data['token'], + 'data' => $decrypted, + 'token' => $decrypted->token, ]); return response()->json([ - 'request_id' => $request->request_id, 'id' => $harim->id, 'city' => $city->edarateShahri()->first()->name_fa, 'province' => $city->province()->first()->name_fa, diff --git a/app/Http/Requests/V3/Dashboard/Harim/PanjareVahed/ReceiveNewRequest.php b/app/Http/Requests/V3/Dashboard/Harim/PanjareVahed/ReceiveNewRequest.php index d5bc528d..3ddf8d7e 100644 --- a/app/Http/Requests/V3/Dashboard/Harim/PanjareVahed/ReceiveNewRequest.php +++ b/app/Http/Requests/V3/Dashboard/Harim/PanjareVahed/ReceiveNewRequest.php @@ -33,12 +33,14 @@ class ReceiveNewRequest extends FormRequest 'plan_group' => 'required', 'plan_title' => 'required', 'worksheet' => 'required', - 'response_options' => 'required', + 'response_options' => 'required|array', + 'response_options.*.id' => 'required|integer', + 'response_options.*.value' => 'required|string', 'isic' => 'required', 'primary_area' => 'required|array', 'primary_area.type' => 'required|string', 'primary_area.coordinates' => 'required|array', - 'data' => 'required|array', + 'data' => 'required|string', ]; } diff --git a/config/harim_web_services.php b/config/harim_web_services.php index 7104519c..3c8268c6 100644 --- a/config/harim_web_services.php +++ b/config/harim_web_services.php @@ -30,4 +30,9 @@ return [ 'password' => env('HARIM_NEED_GUARANTEE_LETTER_PASSWORD'), 'username' => env('HARIM_NEED_GUARANTEE_LETTER_USERNAME'), ], + + 'Get_Info' => [ + 'key' => env('HARIM_ENCRYPTION_KEY'), + 'iv' => env('HARIM_ENCRYPTION_IV'), + ], ];