mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 23:06:08 -06:00
#2677 store module imp.
This commit is contained in:
parent
907d31fcac
commit
b479c89399
@ -1,4 +1,4 @@
|
|||||||
function crudAjax(params, url, type, callback, async = false) {
|
function crudAjax(params, url, type, callback = () => {}, async = false) {
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
type: type,
|
type: type,
|
||||||
data: params,
|
data: params,
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
<?php namespace Visiosoft\LocationModule\Http\Controller;
|
<?php namespace Visiosoft\LocationModule\Http\Controller;
|
||||||
|
|
||||||
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface;
|
use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface;
|
||||||
use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface;
|
use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface;
|
||||||
use Visiosoft\LocationModule\District\Contract\DistrictRepositoryInterface;
|
use Visiosoft\LocationModule\District\Contract\DistrictRepositoryInterface;
|
||||||
@ -112,4 +115,43 @@ class AjaxController extends PublicController
|
|||||||
|
|
||||||
return $query->orderBy($sorting_column, $sorting_type)->get();
|
return $query->orderBy($sorting_column, $sorting_type)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function findLocation()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$validator = Validator::make(request()->all(), [
|
||||||
|
'type' => [
|
||||||
|
'required',
|
||||||
|
Rule::in(['countries', 'cities', 'districts', 'neighborhoods', 'village'])
|
||||||
|
],
|
||||||
|
'id' => 'required|exists:location_' . request()->type,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
throw new \Exception($validator->messages()->first());
|
||||||
|
}
|
||||||
|
|
||||||
|
$dBName = 'location_' . request()->type;
|
||||||
|
$location = DB::table($dBName)
|
||||||
|
->join(
|
||||||
|
$dBName . '_translations as location_trans',
|
||||||
|
$dBName . '.id',
|
||||||
|
'=',
|
||||||
|
'location_trans.entry_id'
|
||||||
|
)
|
||||||
|
->where($dBName . '.id', request()->id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'success' => true,
|
||||||
|
'data' => $location
|
||||||
|
];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'msg' => $e->getMessage()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -76,6 +76,7 @@ class LocationModuleServiceProvider extends AddonServiceProvider
|
|||||||
'admin/location/neighborhoods/create' => 'Visiosoft\LocationModule\Http\Controller\Admin\NeighborhoodsController@create',
|
'admin/location/neighborhoods/create' => 'Visiosoft\LocationModule\Http\Controller\Admin\NeighborhoodsController@create',
|
||||||
'admin/location/neighborhoods/edit/{id}' => 'Visiosoft\LocationModule\Http\Controller\Admin\NeighborhoodsController@edit',
|
'admin/location/neighborhoods/edit/{id}' => 'Visiosoft\LocationModule\Http\Controller\Admin\NeighborhoodsController@edit',
|
||||||
|
|
||||||
|
// AjaxController
|
||||||
'ajax/getCountry' => [
|
'ajax/getCountry' => [
|
||||||
'as' => 'location::getCountry',
|
'as' => 'location::getCountry',
|
||||||
'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getCountries'
|
'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getCountries'
|
||||||
@ -97,6 +98,10 @@ class LocationModuleServiceProvider extends AddonServiceProvider
|
|||||||
'as' => 'location::getVillage',
|
'as' => 'location::getVillage',
|
||||||
'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getVillage'
|
'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getVillage'
|
||||||
],
|
],
|
||||||
|
'api/find-location' => [
|
||||||
|
'as' => 'visiosoft.module.location::api_find_location',
|
||||||
|
'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@findLocation'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user