mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
Merge pull request #1222 from openclassify/dia
#4826 emlak24-theme need this week
This commit is contained in:
commit
e8916c4605
@ -29,7 +29,7 @@ filter.getCats = (catId, divId) => {
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
if ($('input[name="slug"]').val() == "") {
|
||||
if (!$('input[name="slug"]').val()) {
|
||||
$("select[name='currency']").val(default_currency);
|
||||
}
|
||||
|
||||
|
||||
@ -727,4 +727,17 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
|
||||
return $classifieds->paginate($limit, ['*'], 'page', $page);
|
||||
}
|
||||
|
||||
public function getClassifiedsByCoordinates($lat, $lng, $distance = 50)
|
||||
{
|
||||
return $this
|
||||
->currentAds()
|
||||
->whereNotNull('map_Val')
|
||||
->select(
|
||||
DB::raw("*, ( 3959 * acos( cos( radians('$lat') ) * cos( radians( SUBSTRING_INDEX(map_Val, ',', 1) ) ) * cos( radians( SUBSTRING_INDEX(map_Val, ',', -1) ) - radians('$lng') ) + sin( radians('$lat') ) * sin( radians( SUBSTRING_INDEX(map_Val, ',', 1) ) ) ) ) AS distance")
|
||||
)
|
||||
->havingRaw("distance < $distance")
|
||||
->orderBy('distance')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,4 +74,6 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
|
||||
public function getUnexplainedClassifiedsReport();
|
||||
|
||||
public function getNoImageClassifiedsReport();
|
||||
|
||||
public function getClassifiedsByCoordinates($lat, $lng, $distance = 50);
|
||||
}
|
||||
|
||||
@ -177,6 +177,7 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
|
||||
'class/getcats/{id}' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@getCatsForNewAd',
|
||||
'mapJson' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@mapJson',
|
||||
'check_user' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@checkUser',
|
||||
'api/classified/get-by-coordinates' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@getClassifiedsByCoordinates',
|
||||
|
||||
// AjaxController
|
||||
'admin/advs/ajax' => [
|
||||
|
||||
@ -1204,4 +1204,24 @@ class AdvsController extends PublicController
|
||||
$response['maxQuantity'] = $adv->stock;
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getClassifiedsByCoordinates()
|
||||
{
|
||||
\request()->validate([
|
||||
'lat' => 'required',
|
||||
'lng' => 'required',
|
||||
]);
|
||||
|
||||
try {
|
||||
return [
|
||||
'success' => true,
|
||||
'classifieds' => $this->adv_repository->getClassifiedsByCoordinates(\request()->lat, \request()->lng),
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user