create history for webservice

This commit is contained in:
2025-11-04 15:50:08 +03:30
parent 4ba3636ce8
commit 2761f4891a
12 changed files with 171 additions and 81 deletions

View File

@@ -86,23 +86,18 @@ class City extends Model
{
try {
$city = City::query()
->whereRaw("
ST_Contains(
geometry,
ST_GeomFromText('POINT($lng $lat)', 4326)
)
")
->firstOrFail();
}
catch (ModelNotFoundException $exception) {
->whereRaw("ST_Contains(
geometry,
ST_GeomFromText('POINT($lng $lat)', 4326))"
)
->firstOrFail(['id', 'name_fa', 'province_id']);
} catch (ModelNotFoundException $exception) {
$city = City::query()
->orderByRaw("
ST_Distance(
geometry,
ST_GeomFromText('POINT($lng $lat)', 4326)
) ASC
")
->first();
->orderByRaw("ST_Distance(
geometry,
ST_GeomFromText('POINT($lng $lat)', 4326)) ASC"
)
->first(['id', 'name_fa', 'province_id']);
}
return $city;