/**
  * 解析数组
  * 
  * @param       
  * 
  * @author      wen.zhou@bioon.com
  * 
  * @date        2015-09-03 07:49:53
  * 
  * @return      
  */
 private function parseArray($navs)
 {
     // dd($navs);
     $navs = Nav::indexGetnav()->get()->toArray();
     $navIndex = array();
     // dd($navs)
     // foreach($navs as $nav_key => $nav_val){
     //  $cata_path_arr = explode('-', $nav_val->cata_path);
     //  print_r($cata_path_arr);exit;
     // }
     // print_r($navs);exit;
     // foreach($navs as $nav){
     //     $navIndex[$nav['cata_parent_id']]['son'][$nav['id']] = &$navs[$nav['id']];
     // }
     // print_r($navIndex);exit;
     // foreach ($items as $item){
     //     $items[$item['pid']]['son'][$item['id']] = &$items[$item['id']];
     // }
     // return isset($items[0]['son']) ? $items[0]['son'] : array();
     // foreach($navs as $nav_key => $nav_val){
     //     $navIndex[$nav_val->cata_parent_id]['son'][$nav_val->id] = &$navIndex[$nav_val->id];
     //     // $cata_path_arrs = explode('-', $nav_val->cata_path);  // ?
     //     // print_r($cata_path_arr);exit;
     //     // foreach($cata_path_arrs as $cata_path_arr){
     //     //     $navIndex[$cata_path_arr]
     //     // }
     //     // $navIndex[$nav_val->cata_path]['name'] = $nav_val->cata_parent_name;
     //     // $navIndex[$nav_val->cata_path]['son'][$nav_val->id] = $nav_val;
     // }
     foreach ($navs as $nav) {
         if (isset($navs[$nav['cata_parent_id']])) {
             $navs[$nav['cata_parent_id']]['son'][] =& $navs[$nav['id']];
         } else {
             $navIndex[] =& $navs[$nav['id']];
         }
     }
     return $navIndex;
     dd($navIndex);
     exit;
     return view('index.index')->with($navIndex);
 }
 /**
  * 显示nav分类数据
  * 
  * @author wen.zhou@bioon.com 2015-08-04 11:05:54
  * 
  * @return 
  */
 public function getShow(Request $request)
 {
     $draw = $request->input('draw', 1);
     $navList = Nav::select('cata_id', 'cata_name', 'cata_type', 'cata_status', 'cata_path')->get();
     return array("draw" => $draw, "recordsTotal" => $navList->count(), "recordsFiltered" => $navList->count(), "data" => $navList->toArray());
 }
Beispiel #3
0
 public function postNavsInsert()
 {
     $arrInsert = array_except($_POST, array('_token'));
     $nav = Nav::create($arrInsert);
     return redirect('/admin');
 }