function horizontalMenuWidget($min, $cat, $value = array(), $options = array(), $max = 0) { global $registry; $ul = false; $registry['cat'] = $cat; if (count($options) > 0) { foreach ($options as $key => $op) { $ul .= $key . '=' . $op; } } $entry = Cache::remember('rubrics', $min, function () { global $registry; if (is_numeric($registry['cat']) and !ctype_alpha($registry['cat'])) { return \App\Cat::orderBy('sort', 'asc')->posts($registry['cat'])->get(); } else { $slug = \App\Cat::select('id')->where('slug', $registry['cat'])->first(); return \App\Cat::orderBy('sort', 'asc')->posts($slug->id)->get(); } }); $output = '<ul ' . $ul . '>'; if (count($value) > 0) { foreach ($value as $key => $v) { $output .= '<li><a href="' . $key . '">' . $v . '</a></li>'; } } $i = 0; if ($max > 0) { foreach ($entry as $item) { $i++; if ($i <= $max) { $output .= '<li><a href="/cat/' . $item->slug . '">' . $item->name . '</a></li>'; } } if (count($entry) > $max) { $output .= '<li class="more"><a>' . trans('all.more') . ' <i class="fa fa-caret-right"></i></a><ul>'; $i = 0; foreach ($entry as $item) { $i++; if ($i > $max) { $output .= '<li><a href="/cat/' . $item->slug . '">' . $item->name . '</a></li>'; } } $output .= '</ul></li>'; } } else { foreach ($entry as $item) { $i++; $output .= '<li><a href="/cat/' . $item->slug . '">' . $item->name . '</a></li>'; } } $output .= '</ul>'; return $output; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id, User $users) { $item = Article::findOrFail($id); $users = $users->getUsers(['Author', '3rd party content provider', 'Administrator', 'Publisher', 'Frontpage editor', 'Super Admin'], 'name|asc'); //$users = array_pluck($users,'id'); $user_names = array(); $i = 0; foreach ($users as $user) { foreach ($user->details as $u) { $user_names[$user->name] = $u->full_name; } $i++; } $users = array_name($user_names); $child = $item->categories()->select('cat_id')->first(); $images = $item->images()->get(); $image_gallery = [['img' => null, 'title' => null, 'alt' => null, 'source' => null, 'author' => null, 'meta_desc' => null, 'meta_key' => null]]; if (count($images) > 0) { $image_gallery = add_image_array($images); } if (count(Session::get('_old_input')['image']) > 0) { $image_gallery = add_image_array(Session::get('_old_input')['image']); } $checked_cats = ''; if (count(Session::get('_old_input')['cat']) > 0) { $checked_cats = join(',', Session::get('_old_input')['cat']); } $parent = Cat::select('parent')->where('id', $child->cat_id)->first()->parent; //$cats = $cats->select('id','name')->latest()->postextra(['parent'=>2,'id'=>[5,6,7]])->get(); $catid = $child->cat_id; $extra_fields = get_fields($item->extra_fields); $json_extra = ''; if (count($extra_fields) > 0 && !empty($extra_fields)) { $json_extra = json_encode($extra_fields); } if (count(Session::get('_old_input')['extra_fields']) > 0) { $extra_fields = Session::get('_old_input')['extra_fields']; $json_extra = json_encode($extra_fields); } $fields = hasFields([2], ['select' => ['col-sm' => 5], 'input' => ['col-sm' => 5], 'textarea' => ['col-sm' => 9]], $extra_fields); return view('admin.articles.edit', compact('item', 'users', 'fields', 'parent', 'catid', 'image_gallery', 'extra_fields', 'checked_cats', 'json_extra')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $banner = Banner::findOrFail($id); $cats = Cat::select('id', 'name')->posts(26)->get(); $cats = array_id_name($cats); $selected = $banner->categories()->select('cat_id')->where('banner_id', $id)->get()[0]->cat_id; return view('admin.banners.edit', compact('cats', 'banner', 'selected')); }
/** * 获取所有分类 */ public function allCats(Request $request) { $params = $request->get('q'); $datas = Cat::select(['id', 'title'])->where('title', 'like', '%' . $params . '%')->get(); return response()->json($datas); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id, Cat $cats) { $cat = $cats->findOrFail($id); $categories = $cats->select('id', 'name', 'parent')->orderBy('name')->nothis($id)->get(); return view('admin.categories.edit', compact('cat', 'categories')); }
public function showSerialsList(Article $article, $slug) { $catName = Cat::select('name')->where('slug', $slug)->take(1)->get(); $movies = $article->select('title', 'img', 'head', 'body', 'slug')->bycatslug($slug)->language()->published()->latest()->take(get_setting('pagination_num'))->get(); return view('components.lists.serials', compact('movies', 'catName')); }
/** * Cat datas. * * @return \Illuminate\Http\Response */ public function datas() { return Datatables::of(Cat::select('*'))->make(true); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $cat = Cat::select('id', 'name', 'parent')->where('id', $id)->orderBy('name')->first(); $fields = Field::select('id', 'cat_id', 'value', 'trans', 'tag', 'type')->where('cat_id', $cat->id)->get(); return view('admin.fields.index', compact('cat', 'fields')); }