Update Module Province

This commit is contained in:
daeng.deni@dharma.or.id 2023-06-09 00:20:58 +07:00
parent 9915b04fbd
commit c4dd3a03cc
3 changed files with 35 additions and 33 deletions

View File

@ -41,16 +41,41 @@
abort(403, 'Sorry !! You are Unauthorized to view any ' . $this->module->alias . ' !');
}
if (isset($request->country_id) && !empty($request->country_id)) {
if (isset($request->country_id) && !empty($request->country_id)) {
$this->show($request);
return;
}
$countries = Country::all();
$_table = $dataTable->render($this->module->alias . '::province.index', compact('countries'));
if(!empty($_table->data)){
return $_table;
return $dataTable->render($this->module->alias . '::province.index', compact('countries'));
}
/**
* Show the specified resource.
*
* @param int $id
*
* @return Renderable
*/
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 . ' !');
}
$provinces = Province::where('country_id', $request->country_id)->get();
$data = [];
foreach ($provinces as $row) {
$result = [
$row->id => $row->name,
];
$data[] = $result;
}
echo json_encode($data);
}
/**
@ -97,33 +122,6 @@
abort(404);
}
/**
* Show the specified resource.
*
* @param int $id
*
* @return Renderable
*/
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 . ' !');
}
$provinces = Province::where('country_id', $request->country_id)->get();
$data = [];
foreach ($provinces as $row) {
$result = [
$row->id => $row->name,
];
$data[] = $result;
}
echo json_encode($data);
}
/**
* Show the form for editing the specified resource.
*

View File

@ -51,7 +51,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

@ -129,7 +129,11 @@
$(".form_{{$route[0].'_'.$route[1]}}").attr('action', "{{ route($route[0].'.'.$route[1].'.store') }}");
$(".form_{{$route[0].'_'.$route[1]}}").find('input[name="_method"]').remove();
$("#title_form").html("Create {{ucfirst($route[1])}}");
})
});
Inputmask({
"mask" : "99"
}).mask("#{{$route[0].'_'.$route[1]}}_code");
});
</script>
@endpush