Update Module District
This commit is contained in:
parent
645299a3f0
commit
d22ef5fd68
@ -86,9 +86,9 @@
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
|
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
|
||||||
Column::make('city.province.country.name')->title(__('Country')),
|
Column::make('city.province.country.name')->title(__('Country'))->orderable(false),
|
||||||
Column::make('city.province.name')->title(__('Province')),
|
Column::make('city.province.name')->title(__('Province'))->orderable(false),
|
||||||
Column::make('city.name')->title(__('City')),
|
Column::make('city.name')->title(__('City'))->orderable(false),
|
||||||
Column::make('code')->title(__('Area Code')),
|
Column::make('code')->title(__('Area Code')),
|
||||||
Column::make('name')->title(__('Name')),
|
Column::make('name')->title(__('Name')),
|
||||||
Column::computed('status')->title(__('Status'))->width(50)->addClass('text-center')->exportable(false),
|
Column::computed('status')->title(__('Status'))->width(50)->addClass('text-center')->exportable(false),
|
||||||
|
@ -35,14 +35,19 @@
|
|||||||
*
|
*
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
*/
|
*/
|
||||||
public function index(DistrictDataTable $dataTable)
|
public function index(DistrictDataTable $dataTable, Request $request)
|
||||||
{
|
{
|
||||||
if (is_null($this->user) || !$this->user->can($this->module->alias . '.read')) {
|
if (is_null($this->user) || !$this->user->can($this->module->alias . '.read')) {
|
||||||
abort(403, 'Sorry !! You are Unauthorized to view any ' . $this->module->alias . ' !');
|
abort(403, 'Sorry !! You are Unauthorized to view any ' . $this->module->alias . ' !');
|
||||||
}
|
}
|
||||||
|
if (isset($request->city_id) && !empty($request->city_id)) {
|
||||||
|
$this->show($request);
|
||||||
|
return;
|
||||||
|
}
|
||||||
addVendor('chained-select');
|
addVendor('chained-select');
|
||||||
$countries = Country::all();
|
$countries = Country::all();
|
||||||
return $dataTable->render($this->module->alias . '::district.index', compact('countries'));
|
return $dataTable->render($this->module->alias . '::district.index', compact('countries'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,13 +101,24 @@
|
|||||||
*
|
*
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show(Request $request)
|
||||||
{
|
{
|
||||||
if(is_null($this->user) || !$this->user->can($this->module->alias . '.read')) {
|
if(is_null($this->user) || !$this->user->can($this->module->alias . '.read')) {
|
||||||
abort(403, 'Sorry !! You are Unauthorized to view any ' . $this->module->alias . ' !');
|
abort(403, 'Sorry !! You are Unauthorized to view any ' . $this->module->alias . ' !');
|
||||||
}
|
}
|
||||||
|
|
||||||
abort(404);
|
$cities = District::where('city_id', $request->city_id)->get();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
foreach ($cities as $row) {
|
||||||
|
$result = [
|
||||||
|
$row->id => $row->name,
|
||||||
|
];
|
||||||
|
|
||||||
|
$data[] = $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
<span class="required">Area Code</span>
|
<span class="required">Area Code</span>
|
||||||
</label>
|
</label>
|
||||||
<!--end::Label-->
|
<!--end::Label-->
|
||||||
<input type="number" id="{{$route[0].'_'.$route[1]}}_code" minlength="2" maxlength="2" class="form-control form-control-solid" placeholder="Enter Area Code" name="code"/>
|
<input type="string" id="{{$route[0].'_'.$route[1]}}_code" class="form-control form-control-solid" placeholder="Enter Area Code" name="code"/>
|
||||||
</div>
|
</div>
|
||||||
<!--end::Input group-->
|
<!--end::Input group-->
|
||||||
|
|
||||||
|
@ -71,8 +71,12 @@
|
|||||||
$('#{{$route[0].'_'.$route[1]}}_name').val(response.name);
|
$('#{{$route[0].'_'.$route[1]}}_name').val(response.name);
|
||||||
$('#{{$route[0].'_'.$route[1]}}_code').val(response.code);
|
$('#{{$route[0].'_'.$route[1]}}_code').val(response.code);
|
||||||
$('#{{$route[0].'_'.$route[1]}}_country_id').val(response.city.province.country_id).change();
|
$('#{{$route[0].'_'.$route[1]}}_country_id').val(response.city.province.country_id).change();
|
||||||
|
setTimeout(function () {
|
||||||
$('#{{$route[0].'_'.$route[1]}}_province_id').val(response.city.province_id).change();
|
$('#{{$route[0].'_'.$route[1]}}_province_id').val(response.city.province_id).change();
|
||||||
$('#{{$route[0].'_'.$route[1]}}_city_id').val(response.city.city_id).change();
|
}, 1000);
|
||||||
|
setTimeout(function () {
|
||||||
|
$('#{{$route[0].'_'.$route[1]}}_city_id').val(response.city_id).change();
|
||||||
|
}, 2000);
|
||||||
$('#{{$route[0].'_'.$route[1]}}_status').prop('checked', response.status==="1");
|
$('#{{$route[0].'_'.$route[1]}}_status').prop('checked', response.status==="1");
|
||||||
$('.form_{{$route[0].'_'.$route[1]}}').attr('action', '{{ URL::to('/'.$route[0].'/'.$route[1].'/') }}/' + response.id).append('<input type="hidden" name="_method" value="PUT">');
|
$('.form_{{$route[0].'_'.$route[1]}}').attr('action', '{{ URL::to('/'.$route[0].'/'.$route[1].'/') }}/' + response.id).append('<input type="hidden" name="_method" value="PUT">');
|
||||||
$('#kt_modal_{{$route[0].'_'.$route[1]}}').modal('show');
|
$('#kt_modal_{{$route[0].'_'.$route[1]}}').modal('show');
|
||||||
|
@ -142,6 +142,10 @@
|
|||||||
parents: "#{{$route[0].'_'.$route[1]}}_province_id",
|
parents: "#{{$route[0].'_'.$route[1]}}_province_id",
|
||||||
url: "/master/city"
|
url: "/master/city"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Inputmask({
|
||||||
|
"mask" : "99.99.99"
|
||||||
|
}).mask("#{{$route[0].'_'.$route[1]}}_code");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
Loading…
Reference in New Issue
Block a user