tree(); $data = $this->showimg(); $new = $this->shownews('news', 4); $tong = $this->shownews('tzgg', 5); $wjzd = $this->shownews('wjzd', 8); $kstd = $this->shownews('kstd', 4); $xyfc = $this->shownews('xyfc', 5); return view('web.content', compact('data', 'new', 'tong', 'wjzd', 'kstd', 'xyfc')); } public function foot() { $data = DB::table('sites')->where('status', '=', '0')->orderBy('order', 'DESC')->select('keys', 'value')->get(); return $data; } public function tree($parentid = 0, $columnid = 1) { $rows = Column::where([['parentid', '=', $parentid], ['columnid', '=', $columnid]])->orderBy('order', 'ASC')->select('name', 'id', 'url', 'parentid')->get(); $rows = $rows->toArray(); $arr = []; if (sizeof($rows) != 0) { foreach ($rows as $key => $val) { // $val['open']='true'; $val['children'] = $this->tree($val['id']); $arr[] = $val; } return $arr; } return; } public function show($name, Column $table) { $re = $table->showid($name); // dd($re->toArray()); if ($re[0]->type == 0) { $data = DB::table('articles')->where('colid', '=', $re[0]->id)->select('title', 'id', 'pushtime')->get(); $n = $table->where('keys', '=', $name)->select('name', 'url', 'parentid')->get(); // dd($n); if ($n[0]->parentid !== 0) { $m = $table->where('id', '=', $n[0]->parentid)->select('name')->get(); } return view('web.list', compact('data', 'm', 'n')); } else { $n = $table->where('keys', '=', $name)->select('name', 'url', 'parentid')->get(); // dd($n); if ($n[0]->parentid !== 0) { $m = $table->where('id', '=', $n[0]->parentid)->select('name')->get(); } $data = DB::table('articles')->where('colid', '=', $re[0]->id)->get(); return view('web.detail', compact('data', 'm', 'n')); } } public function showinfo($id) { $data = DB::table('articles')->where('id', '=', $id)->get(); return view('demo.detail', compact('data')); } public function test(Request $request) { $list = DB::table('sites')->orderBy('id', 'desc')->select('id', 'name', 'keys', 'value')->get(); return response(['code' => '0', 'msg' => '', 'data' => $list]); // return $list; } public function showimg() { $data = DB::table('posters')->where('status', '=', '0')->get(); return $data; } // public function shownews($parentid,$n){ // $data=DB::table('columns')->where([['status','=',0],['parentid','=',$parentid]])->select( // 'id','atype','name','url','keys')->get(); // foreach ($data as $k=>$v){ // $re=DB::table('articles')->where('colid','=',$v->id)-> // orderBy('pushtime','desc')->limit($n)->get(); // if ($re){ // $data['articles']=$re; // } // } // } public function test1() { return view('demo.test'); } public function shownews($keys, $n) { $data = DB::table('columns')->where('keys', '=', $keys)->select('id', 'name', 'url')->get(); $re = DB::table('articles')->where('colid', '=', $data[0]->id)->orderBy('pushtime', 'desc')->limit($n)->get(); if ($re) { $data[0]->articles = $re; } return $data; } }