Merge pull request #83 from witelgroup/feature/UpdateHarim
Feature/update harim
This commit is contained in:
@@ -21,6 +21,17 @@ class PanjareVahedController extends Controller
|
||||
|
||||
public function receiveNewRequest(ReceiveNewRequest $request): JsonResponse
|
||||
{
|
||||
$iv = config('harim_web_services.Harim_Info.iv');
|
||||
$keyString = config('harim_web_services.Harim_Info.keyString');
|
||||
|
||||
$key = hash('sha256',$keyString, true);
|
||||
|
||||
$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'])).'))';
|
||||
$result = DB::selectOne('SELECT ST_AsText(ST_PointOnSurface(ST_GeomFromText(?, 4326))) AS point', [$wkt]);
|
||||
preg_match('/POINT\(([^ ]+) ([^ ]+)\)/', $result->point, $matches);
|
||||
@@ -43,7 +54,11 @@ class PanjareVahedController extends Controller
|
||||
|
||||
$state = HarimStates::BARESI_EDARE_SHAHRESTAN->value;
|
||||
|
||||
$harim = Harim::query()->create([
|
||||
$harim = Harim::query()->firstOrCreate(
|
||||
[
|
||||
'panjare_vahed_id' => $request->request_id
|
||||
],
|
||||
[
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'panjare_vahed_id' => $request->request_id,
|
||||
@@ -62,12 +77,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' => $decodedString,
|
||||
'token' => $decodedArray['token'],
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'request_id' => $request->request_id,
|
||||
'id' => $harim->id,
|
||||
'city' => $city->edarateShahri()->first()->name_fa,
|
||||
'province' => $city->province()->first()->name_fa,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\PanjareVahed;
|
||||
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
@@ -33,12 +34,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',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -30,4 +30,9 @@ return [
|
||||
'password' => env('HARIM_NEED_GUARANTEE_LETTER_PASSWORD'),
|
||||
'username' => env('HARIM_NEED_GUARANTEE_LETTER_USERNAME'),
|
||||
],
|
||||
|
||||
'Harim_Info' => [
|
||||
'key' => env('HARIM_ENCRYPTION_KEY'),
|
||||
'iv' => env('HARIM_ENCRYPTION_IV'),
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user