/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { //获取商品类型 $type_list = Type::all(); //获取商品分类 $categoryData = Category::get(); $cate_list = getTree($categoryData); return view('admin.goods.create', compact('type_list', 'cate_list')); }
/** * edit data page * @param int id * @return view */ public function edit($id) { $categoryData = Category::get(); $ids = getChild($categoryData, $id); $ids[] = $id; $category = getTree($categoryData); $info = Category::findOrFail($id); return view('admin.category.edit', compact('ids', 'category', 'info')); }
protected function sidebarCategory() { if (!Cache::has('_tags')) { $tags = Tagged::join('tags', 'tagged.tag_id', '=', 'tags.id')->select('tags.id', DB::raw('count(tag_id) as total_tags'), 'tags.tag_name')->groupBy('tagged.tag_id')->take(20)->get(); Cache::put('_tags', $tags, 60); } if (!Cache::has('_category')) { $category = Category::get(); Cache::put('_category', $category, 60); } if (!Cache::has('_recent')) { $recent = Diary::where('status', 1)->orderBy('created_at', 'desc')->take(5)->get(['title', 'id']); Cache::put('_recent', $recent, 60); } view()->composer('site.partials.sidebar', function ($view) { $view->with('navData', ['category' => Cache::get('_category'), 'recents' => Cache::get('_recent'), 'tags' => Cache::get('_tags')]); }); }
public function create() { $categories = Category::get()->lists('title', 'id'); return view('news.create', ['categories' => $categories]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return Category::get(); }
public function category($category) { $category = models\Category::get($category); $messages = Session::messages(); return $this->tpl->display(__METHOD__, get_defined_vars()); }
public function getEdit($id) { $cat = Category::get(); $diary = Diary::find($id); return view('admin.diary.editdiary', ['pageInfo' => ['siteTitle' => 'Edit Diary', 'pageHeading' => 'Edit Diary', 'pageHeadingSlogan' => 'I write here what I learn'], 'data' => ['category' => $cat, 'diary' => $diary]]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $data = Category::get(); return response()->json($data); }
/** * Show the application dashboard to the user. * * @return Response */ public function listCategory() { return view('admin.partials.list_category', ['categories' => Category::get()]); }