Update Module District

This commit is contained in:
daeng.deni@dharma.or.id 2023-06-09 00:21:32 +07:00
parent 645299a3f0
commit d22ef5fd68
5 changed files with 33 additions and 9 deletions

View File

@ -86,9 +86,9 @@
{
return [
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
Column::make('city.province.country.name')->title(__('Country')),
Column::make('city.province.name')->title(__('Province')),
Column::make('city.name')->title(__('City')),
Column::make('city.province.country.name')->title(__('Country'))->orderable(false),
Column::make('city.province.name')->title(__('Province'))->orderable(false),
Column::make('city.name')->title(__('City'))->orderable(false),
Column::make('code')->title(__('Area Code')),
Column::make('name')->title(__('Name')),
Column::computed('status')->title(__('Status'))->width(50)->addClass('text-center')->exportable(false),

View File

@ -35,14 +35,19 @@
*
* @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')) {
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');
$countries = Country::all();
return $dataTable->render($this->module->alias . '::district.index', compact('countries'));
}
/**
@ -96,13 +101,24 @@
*
* @return Renderable
*/
public function show($id)
public function show(Request $request)
{
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(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);
}
/**

View File

@ -77,7 +77,7 @@
<span class="required">Area Code</span>
</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>
<!--end::Input group-->

View File

@ -71,8 +71,12 @@
$('#{{$route[0].'_'.$route[1]}}_name').val(response.name);
$('#{{$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]}}_province_id').val(response.city.province_id).change();
$('#{{$route[0].'_'.$route[1]}}_city_id').val(response.city.city_id).change();
setTimeout(function () {
$('#{{$route[0].'_'.$route[1]}}_province_id').val(response.city.province_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");
$('.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');

View File

@ -142,6 +142,10 @@
parents: "#{{$route[0].'_'.$route[1]}}_province_id",
url: "/master/city"
});
Inputmask({
"mask" : "99.99.99"
}).mask("#{{$route[0].'_'.$route[1]}}_code");
});
</script>
@endpush