Exemplo n.º 1
0
 /**
  * Include articles.
  *
  * @param  \App\Tag                      $tag
  * @param  \League\Fractal\ParamBag|null $params
  * @return  \League\Fractal\Resource\Collection
  * @throws  \Exception
  */
 public function includeArticles(Tag $tag, ParamBag $params = null)
 {
     $transformer = new \App\Transformers\ArticleTransformer($params);
     $parsed = $this->getParsedParams();
     $articles = $tag->articles()->limit($parsed['limit'])->offset($parsed['offset'])->orderBy($parsed['sort'], $parsed['order'])->get();
     return $this->collection($articles, $transformer);
 }
 public function show(Tag $tag)
 {
     $articles = $tag->articles()->published('<')->get();
     //        if published date is not required then
     //        below line can be used :)
     //        $articles = $tag->articles
     return view('articles.index', compact('articles'));
 }
Exemplo n.º 3
0
 public function show(Tag $tag, urlRequest $request)
 {
     //query within tag
     if ($search = $request->query('q')) {
         $articles = $tag->articles()->search($search)->orderBy('created_at', 'desc')->simplepaginate(18);
     } elseif ($search = $request->query('id')) {
         $articles = $tag->articles()->where('id', '<', $search)->orderBy('created_at', 'desc')->simplepaginate(18);
     } else {
         //获取这个tag的articles并用articles.index反应
         $articles = $tag->articles()->orderBy('created_at', 'desc')->simplepaginate(18);
     }
     $articles->setPath($tag->name);
     //sidebar
     $hotimgs = \App\Article::where('type', 'LIKE', "%jpg%")->orderBy('vote_count', 'desc')->take(10)->get();
     //return $hotimgs;
     $hotreplies = \App\Reply::orderBy('vote_count', 'desc')->limit(10)->get();
     return view('articles.index', compact('articles', 'search', 'hotimgs', 'hotreplies'));
 }
Exemplo n.º 4
0
 public function show(Tag $tag)
 {
     // if (Gate::denies('update', $tag)) {
     //     abort(403, Message::HTTP_403);
     // }
     // $this->authorize('update', $tag);
     // if (auth()->user()->can('update', $tag)) {
     //     return 'You can';
     // }
     $articles = $tag->articles()->paginate(5);
     return view('articles.index', compact('articles'));
 }
 public function show(Tag $tag)
 {
     $articles = $tag->articles()->published()->get();
     return view('articles.index', compact('articles'));
 }
 public function show(Tag $tags)
 {
     $articles = $tags->articles()->published()->get();
     return view("articles.index", compact("articles"));
 }
Exemplo n.º 7
0
 /**
  * @param Tag $tag
  * @return Tag
  */
 public function show(Tag $tag)
 {
     $articles = $tag->articles()->published()->get();
     return view('articles.index')->with(['articles' => $articles]);
 }
Exemplo n.º 8
0
 /**
  * Hiển thị thông tin bài viết theo tag
  *
  * @param  Tag $tag
  * @return Response
  */
 public function listArticles(Tag $tag)
 {
     $articles = $tag->articles()->active()->orderBy('published_at', 'desc')->paginate(config('blog.record_per_page'));
     return view('tags.list_articles', compact('tag', 'articles'));
 }
Exemplo n.º 9
0
 public function show(Tag $tag)
 {
     return $tag->articles()->published()->get();
     // Preco nefunguje?
 }
Exemplo n.º 10
0
 public function show(Tag $tag)
 {
     $articles = $tag->articles()->orderBy('created_at')->get();
     return view('articles.index', compact('articles'));
 }
Exemplo n.º 11
0
 public function show(Tag $tag)
 {
     $articles = $tag->articles()->where('is_visible', true)->latest()->paginate(10);
     return view('tag.show', compact('articles', 'tag'));
 }
Exemplo n.º 12
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Tag $tag)
 {
     $articles = $tag->articles()->get();
     return view('tags.show', compact('tag', 'articles'));
 }
Exemplo n.º 13
0
 /**
  * Include articles.
  *
  * @param  \App\Tag                      $tag
  * @param  \League\Fractal\ParamBag|null $params
  * @return  \League\Fractal\Resource\Collection
  * @throws  \Exception
  */
 public function includeArticles(Tag $tag, ParamBag $params = null)
 {
     list($limit, $offset, $orderCol, $orderBy) = $this->calculateParams($params);
     $articles = $tag->articles()->limit($limit)->offset($offset)->orderBy($orderCol, $orderBy)->get();
     return $this->collection($articles, new \App\Transformers\ArticleTransformer());
 }
Exemplo n.º 14
0
 /**
  * Show articles related to tag
  *
  * @param  Tag    $tag
  * @return Response
  */
 public function show(Tag $tag)
 {
     $data['articles'] = $tag->articles()->published()->get();
     return view('articles.index', $data);
 }