Skip to content

Commit

Permalink
Improve moduls controller naming column, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
fherryfherry committed Aug 4, 2016
1 parent dd91e0f commit 66ba6ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
20 changes: 11 additions & 9 deletions app/Http/Controllers/ControllerMaster/ModulsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public function __construct() {

$this->col = array();
$this->col[] = array('label'=>'Sorting','field'=>'sorting');
$this->col[] = array("label"=>"Nama","field"=>"name");
$this->col[] = array("label"=>"Name","field"=>"name");
$this->col[] = array("label"=>"Path","field"=>"path");
$this->col[] = array("label"=>"Table","field"=>"table_name");
$this->col[] = array("label"=>"Controller","field"=>"controller");
$this->col[] = array("label"=>"Group","field"=>"id_cms_moduls_group","join"=>"cms_moduls_group,nama_group");
$this->col[] = array("label"=>"Active","field"=>"is_active","callback_php"=>"(%field%)?'<span class=\"label label-success\">Active</span>':'<span class=\"label label-default\">Not Active</span>'");

$this->form = array();
$this->form[] = array("label"=>"Nama","name"=>"name");
$this->form[] = array("label"=>"Name","name"=>"name");

$exception_table = array('cms_dashboard','cms_logs','cms_moduls','cms_moduls_group','cms_privileges','cms_privileges_roles','cms_users','cms_apicustom','cms_settings','cms_companies','cms_filemanager');
$tables = DB::select('SHOW TABLES');
Expand All @@ -49,14 +49,16 @@ public function __construct() {



$this->form[] = array("label"=>"Table Name","name"=>"table_name","type"=>"select","dataenum"=>$tables_list);
$this->form[] = array("label"=>"Table Name","name"=>"table_name","type"=>"select","dataenum"=>$tables_list);

$this->form[] = array("label"=>"Route","name"=>"path","value"=>"admin/","jquery"=>"
$('#table_name').change(function() {
var v = $(this).val();
$('#path').val('admin/'+v);
})
");

$this->form[] = array("label"=>"Controller","name"=>"controller","type"=>"text","placeholder"=>"Auto Generated");

$this->form[] = array("label"=>"SQL Where Query","name"=>"sql_where","type"=>"text","placeholder"=>"Example : columnname = value AND columnname2 = value2","help"=>"You can use alias [admin_id],[admin_id_companies]");

Expand Down Expand Up @@ -175,7 +177,7 @@ public function getArrSorting($id,$tipe) {
DB::table('cms_moduls')->where('id_cms_moduls_group',$row->id_cms_moduls_group)->where('sorting',$new_sorting)->update(array('sorting'=>$row->sorting));
DB::table('cms_moduls')->where('id',$id)->update(array('sorting'=>$new_sorting));

return redirect()->back()->with(['message'=>"Berhasil sorting data !",'message_type'=>'success']);
return redirect()->back()->with(['message'=>"Sort the data success !",'message_type'=>'success']);
}


Expand All @@ -186,7 +188,7 @@ public function postAddSave() {

//Generate Controller
$route_basename = basename(Request::get('path'));
$this->arr['controller'] = generate_controller(Request::get('table_name'),$route_basename);
if($this->arr['controller']=='') $this->arr['controller'] = generate_controller(Request::get('table_name'),$route_basename);

DB::table($this->table)->insert($this->arr);

Expand All @@ -211,9 +213,9 @@ public function postAddSave() {

$ref_parameter = Request::input('ref_parameter');
if(Request::get('referal')) {
return redirect(Request::get('referal'))->with(['message'=>'Berhasil Tambah Data !','message_type'=>'success']);
return redirect(Request::get('referal'))->with(['message'=>'Add new data success !','message_type'=>'success']);
}else{
return redirect($this->mainpath().'/edit/'.$lastid.'?'.$ref_parameter)->with(['message'=>"Berhasil tambah data !",'message_type'=>'success']);
return redirect($this->mainpath().'/edit/'.$lastid.'?'.$ref_parameter)->with(['message'=>"Add new data success !",'message_type'=>'success']);
}

}
Expand All @@ -227,7 +229,7 @@ public function postEditSave($id) {

//Generate Controller
$route_basename = basename(Request::get('path'));
$this->arr['controller'] = generate_controller(Request::get('table_name'),$route_basename);
if($this->arr['controller']=='') $this->arr['controller'] = generate_controller(Request::get('table_name'),$route_basename);

DB::table($this->table)->where($this->primkey,$id)->update($this->arr);

Expand All @@ -238,7 +240,7 @@ public function postEditSave($id) {
DB::table("cms_moduls")->where("id",$l->id)->update(array("sorting"=>$s));
$s++;
}
return redirect()->back()->with(['message'=>"Berhasil update data !",'message_type'=>'success']);
return redirect()->back()->with(['message'=>"Update data success !",'message_type'=>'success']);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public function __construct() {

$this->col = array();
$this->col[] = array("label"=>"Sorting","field"=>"sorting_group");
$this->col[] = array("label"=>"Nama","field"=>"nama_group");
$this->col[] = array("label"=>"Name","field"=>"nama_group");
$this->col[] = array("label"=>"Is Group","field"=>"is_group");

$this->form = array();
$this->form[] = array("label"=>"Nama","name"=>"nama_group");
$this->form[] = array("label"=>"Name","name"=>"nama_group");
$this->form[] = array("label"=>"Icon","name"=>"icon_group","type"=>"radio","dataenum"=>array(
"fa fa-cog|<i class='fa fa-cog'></i>",
"fa fa-comment|<i class='fa fa-comment'></i>",
Expand Down Expand Up @@ -103,7 +103,7 @@ public function getArrSorting($id,$tipe) {
DB::table('cms_moduls_group')->where('sorting_group',$new_sorting)->update(array('sorting_group'=>$row->sorting_group));
DB::table('cms_moduls_group')->where('id',$id)->update(array('sorting_group'=>$new_sorting));

return redirect()->back()->with(['message'=>"Berhasil sorting data !",'message_type'=>'success']);
return redirect()->back()->with(['message'=>"Sort data success !",'message_type'=>'success']);
}

}

0 comments on commit 66ba6ef

Please sign in to comment.