public function show($tag) { $rs = Tag::where('tag', $tag)->get(); $arr = array(); foreach ($rs as $v) { array_push($arr, $v->article_id); } $articles = Article::whereIn('id', $arr)->get(); $tags = Tag::select('tag')->distinct()->get(); return view('member.tags.show', compact('tag', 'tags', 'articles')); }
public function index(Request $request) { $page = $request->get('page') ?: 1; $tags = Tag::select('tag')->distinct()->get(); $articles = Article::latest()->where('published_at', '<=', Carbon::now())->skip(($page - 1) * self::PAGE_SIZE)->limit(10)->get(); $total = Article::latest()->where('published_at', '<=', Carbon::now())->get()->count(); $cates = Cate::all(); $teams = Team::where('user_id', \Auth::user()->id)->get(); $action = 'articles'; $pageData['totalPage'] = ceil($total / self::PAGE_SIZE); $pageData['currentPage'] = $page; return view('member.articles.index', compact('articles', 'tags', 'cates', 'teams', 'articles', 'pageData')); }
/** * Display the home page. */ public function index() { $carousel_news = Article::select('id', 'title', 'page_image')->where('is_checked', true)->where('is_carousel', true)->published()->get(); $latest_news = Article::select('id', 'title', 'intro', 'page_image')->where('is_checked', true)->published()->orderBy('published_at', 'desc')->take(4)->get(); $ads = Ad::select('url', 'name', 'image_path')->orderBy('created_at', 'desc')->take(2)->get(); // get the index article $tags = Tag::select('id', 'name')->where('show_index', true)->get(); $index_articles = array(); foreach ($tags as $tag) { $tag['articles'] = $tag->articles()->select('article_id', 'title', 'intro', 'page_image')->where('is_checked', true)->published()->orderBy('published_at', 'desc')->take(3)->get(); $index_articles[] = $tag; } return view('front.index')->with('carousel_news', $carousel_news)->with('latest_news', $latest_news)->with('ads', $ads)->with('index_articles', $index_articles); }
public function show($id) { $user = User::findOrFail($id); $tags = Tag::select('tag')->distinct()->where('user_id', $id)->get(); $articles = Article::where('user_id', $id)->orderby('published_at', 'desc')->get(); //博主访客加1 if (\Auth::user()->id != $id) { $r = FlowTrace::where(['user_id' => $id, 'time' => substr(Carbon::now(), 0, 10)])->first(); if ($r) { $r->increment('daycount'); } else { FlowTrace::create(array('user_id' => $id, 'time' => substr(Carbon::now(), 0, 10), 'daycount' => 1)); } User::where('id', $id)->increment('score'); } return view("member.users.show", compact('user', 'tags', 'articles')); }
public function getAllwithPosts() { return Tag::select('id', 'title')->with(['posts' => function ($q) { $q->select('id', 'title')->active(); }])->get(); }
/** * Bootstrap any application services. * * @return void */ public function boot() { view()->composer('front.nav', function ($view) { view()->share('tags', Tag::select('id', 'name')->orderBy('id', 'asc')->get()); }); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($slug) { return view('admin.articles.edit', ['article' => Article::with('tags', 'category')->where('slug', $slug)->firstOrFail(), 'categories' => Category::select('id', 'name')->get(), 'tags' => Tag::select('id', 'name')->get()]); }
/** * 获取不同筛选条件中的值 * @method getCondations * @return [type] [description] */ public function getCondations() { $data['instrument'] = Instrument::select('id', 'name')->get(); $data['press'] = \App\Press::select('id', 'name')->get(); $data['tag'] = \App\Tag::select('id', 'name')->get(); // $data['operator'] = \App\User::select('id', 'name')->with('musics')->whereHas('musics', function ($query) { // $query->groupby('operator'); // })->groupby('id')->get(); $data['operator'] = \App\User::select('id', 'name')->whereHas('musics', function ($query) { $query->groupby('operator'); })->groupby('id')->get(); $data['organizer'] = \App\Organizer::select('id', 'name')->get(); return $data; // $data['status'] = 'sdfsdfsdfsdfsdfsdfsdfdsf'; // return $data; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $product = $this->productRepository->findById($id); if (auth()->user()->id != $product->user_id) { return redirect()->home(); } $categories_list = $this->categoryRepository->getParentsAndChildrenList(true); //Category::lists('name', 'id')->all(); $tags_list = Tag::select('name', 'price', 'id')->get(); $options_list = Option::select('name', 'description', 'price', 'id')->get(); $selected_categories = $product->categories()->select('categories.id AS id')->lists('id')->all(); $selected_tags = $product->tags()->select('tags.id AS id')->lists('id')->all(); return view('products.edit')->with(compact('product', 'categories_list', 'tags_list', 'options_list', 'selected_categories', 'selected_tags')); }