nest('child','content.menu_admin.index',$datas); return $this->bsGetView('content.menu_admin.index', $datas); } public function admin_data($id) { if ($id == 'admin') { if(Auth::user()->role_id==7) { $data = DB::select("SELECT *,id as list_menu FROM ref_role order by id desc"); } else { $data = DB::select("SELECT *,id as list_menu FROM ref_role WHERE id not in (7) order by id desc"); } }else{ $data = DB::select("SELECT user_type_name as description,user_type_uid as list_menu FROM reff_user_type order by user_type_uid desc"); } return DataTables::of($data) ->addColumn('action', function ($data) { return '
'; }) ->editColumn('list_menu',function($data) use($id) { if ($id == 'admin') { $getMenu = DB::select("SELECT * from menu_privilege rrm join menu rm on rm.menu_uid = rrm.menu_uid where group_id = ? and has_children is true order by rm.menu_uid",[$data->list_menu]); $menu_list = ''; foreach ($getMenu as $key => $v) { $menu_list .= ''.$v->menu.''; } }else{ $getMenu = DB::select("SELECT * from privilege rrm join menu_cms rm on rm.menu_cms_uid = rrm.menu_cms_uid where user_type_uid = ? and has_children is true order by rm.menu_cms_uid",[$data->list_menu]); $menu_list = ''; foreach ($getMenu as $key => $v) { $menu_list .= ''.$v->menu_cms.''; } } return $menu_list; }) ->rawColumns(['list_menu','action']) ->make(true); } public function admin_menu_get(Request $request,$id) { if ($id == 'admin') { $data = DB::select("SELECT * FROM menu_privilege where group_id = ".$request->post('id')); }else{ $data = DB::select("SELECT *,menu_cms_uid as menu_uid FROM privilege where user_type_uid = ".$request->post('id')); } return json_encode($data); } public function admin_store(Request $request,$id) { if ($id == 'admin') { DB::table('menu_privilege')->where('group_id', $request->post('get_id'))->delete(); $menu_id = $request->post('menu_id'); if ($menu_id) { foreach ($menu_id as $key => $v) { // $seq = DB::table('menu_privilege')->max('id'); DB::table('menu_privilege')->insert([ // 'id' => $seq+1, 'group_id' => $request->post('get_id'), 'menu_uid' => $v, 'p_menu' => true ]); } } }else{ DB::table('privilege')->where('user_type_uid', $request->post('get_id'))->delete(); $menu_id = $request->post('menu_id'); if ($menu_id) { foreach ($menu_id as $key => $v) { // $seq = DB::table('menu_privilege')->max('id'); DB::table('privilege')->insert([ // 'id' => $seq+1, 'user_type_uid' => $request->post('get_id'), 'menu_cms_uid' => $v ]); } } } return response()->json([ 'rc' => 0, 'rm' => "Berhasil" ]); } }