diff --git a/Http/Controllers/ProvinceController.php b/Http/Controllers/ProvinceController.php index c153c74..3c401ac 100644 --- a/Http/Controllers/ProvinceController.php +++ b/Http/Controllers/ProvinceController.php @@ -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. * diff --git a/Resources/views/province/_form.blade.php b/Resources/views/province/_form.blade.php index a38e785..8d2120e 100644 --- a/Resources/views/province/_form.blade.php +++ b/Resources/views/province/_form.blade.php @@ -51,7 +51,7 @@ Area Code - + diff --git a/Resources/views/province/index.blade.php b/Resources/views/province/index.blade.php index d2edb9a..1722eb9 100644 --- a/Resources/views/province/index.blade.php +++ b/Resources/views/province/index.blade.php @@ -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"); }); @endpush