/** * 菜单列表的api * * @param * * @author wen.zhou@bioon.com * * @date 2015-10-17 00:44:34 * * @return */ public function getApimenulist(MenuContract $menuCon) { /*获取参数*/ $draw = request('draw', 1); $start = request('start', 0); $length = request('length', 10); $search = request('search.value', ''); /*获取菜单*/ $obj_menus = new Menu(); $count = $obj_menus->count(); $obj_menus = $obj_menus->with('parentmenu')->where('parent_id', '=', '1'); $filterCount = $obj_menus->count(); if (!empty($search)) { $obj_menus = $obj_menus->where('name', 'like', "%{$search}%"); } /*分页*/ if ($length != -1) { $obj_menus = $obj_menus->offset($start)->limit($length); } $result_menus = $obj_menus->get(); $menus = $result_menus->toArray(); foreach ($result_menus as $key => $result_menu) { $menus[$key]['update'] = $this->current_user->can('update.menus'); $menus[$key]['delete'] = $this->current_user->can('delete.menus'); } $returnData = ["draw" => $draw, "recordsTotal" => $count, "recordsFiltered" => $filterCount, 'data' => $menus]; return response()->json($returnData); }