improve code in controller and form request for V3 whit pint package
This commit is contained in:
@@ -21,8 +21,8 @@ class PanjareVahedController extends Controller
|
||||
|
||||
public function receiveNewRequest(ReceiveNewRequest $request): JsonResponse
|
||||
{
|
||||
$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]);
|
||||
$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);
|
||||
|
||||
try {
|
||||
@@ -32,8 +32,7 @@ class PanjareVahedController extends Controller
|
||||
ST_GeomFromText('POINT($matches[1] $matches[2])', 4326))"
|
||||
)
|
||||
->firstOrFail(['id', 'name_fa', 'province_id']);
|
||||
}
|
||||
catch (ModelNotFoundException $exception){
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
$city = City::query()
|
||||
->orderByRaw("ST_Distance(
|
||||
geometry,
|
||||
@@ -126,7 +125,6 @@ class PanjareVahedController extends Controller
|
||||
|
||||
$harim = Harim::query()->firstWhere('panjare_vahed_id', '=', $request->request_id);
|
||||
|
||||
|
||||
$harim->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
|
||||
Reference in New Issue
Block a user