fix last code for this part
This commit is contained in:
@@ -21,12 +21,16 @@ class PanjareVahedController extends Controller
|
|||||||
|
|
||||||
public function receiveNewRequest(ReceiveNewRequest $request): JsonResponse
|
public function receiveNewRequest(ReceiveNewRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$iv = config('harim_web_services.Get_Info.iv');
|
$iv = config('harim_web_services.Harim_Info.iv');
|
||||||
$keyString = config('harim_web_services.Get_Info.keyString');
|
$keyString = config('harim_web_services.Harim_Info.keyString');
|
||||||
|
|
||||||
$key = hash('sha256',$keyString, true);
|
$key = hash('sha256',$keyString, true);
|
||||||
|
|
||||||
$decrypted = openssl_decrypt($request->data, 'aes-256-cbc', $key, false, $iv);
|
$decrypted = openssl_decrypt($request->data,'aes-256-cbc',$key,false, $iv);
|
||||||
|
|
||||||
|
$decodedString = json_decode($decrypted);
|
||||||
|
$decodedArray = json_decode($decodedString, true);
|
||||||
|
|
||||||
|
|
||||||
$wkt = 'POLYGON(('.implode(',', array_map(fn ($c) => "{$c[0]} {$c[1]}", $request->primary_area['coordinates'])).'))';
|
$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]);
|
$result = DB::selectOne('SELECT ST_AsText(ST_PointOnSurface(ST_GeomFromText(?, 4326))) AS point', [$wkt]);
|
||||||
@@ -69,8 +73,8 @@ class PanjareVahedController extends Controller
|
|||||||
'response_options' => json_encode($request->response_options),
|
'response_options' => json_encode($request->response_options),
|
||||||
'isic' => $request->isic,
|
'isic' => $request->isic,
|
||||||
'primary_area' => json_encode($request->primary_area),
|
'primary_area' => json_encode($request->primary_area),
|
||||||
'data' => $decrypted,
|
'data' => $decodedString,
|
||||||
'token' => $decrypted->token,
|
'token' => $decodedArray['token'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|||||||
@@ -46,11 +46,21 @@ class ReceiveNewRequest extends FormRequest
|
|||||||
|
|
||||||
protected function failedValidation(Validator $validator)
|
protected function failedValidation(Validator $validator)
|
||||||
{
|
{
|
||||||
$response = response()->json([
|
if ($validator->errors()->has('request_id') && str_contains($validator->errors()->first('request_id'), 'unique'))
|
||||||
'statusCode' => 422,
|
{
|
||||||
'message' => 'invalid inputs',
|
$response = response()->json([
|
||||||
'errors' => $validator->errors(),
|
'statusCode' => 201,
|
||||||
], 422);
|
'message' => 'already stored',
|
||||||
|
], 201);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$response = response()->json([
|
||||||
|
'statusCode' => 422,
|
||||||
|
'message' => 'invalid inputs',
|
||||||
|
'errors' => $validator->errors(),
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
throw new HttpResponseException($response);
|
throw new HttpResponseException($response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ return [
|
|||||||
'username' => env('HARIM_NEED_GUARANTEE_LETTER_USERNAME'),
|
'username' => env('HARIM_NEED_GUARANTEE_LETTER_USERNAME'),
|
||||||
],
|
],
|
||||||
|
|
||||||
'Get_Info' => [
|
'Harim_Info' => [
|
||||||
'key' => env('HARIM_ENCRYPTION_KEY'),
|
'key' => env('HARIM_ENCRYPTION_KEY'),
|
||||||
'iv' => env('HARIM_ENCRYPTION_IV'),
|
'iv' => env('HARIM_ENCRYPTION_IV'),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user