List articles by tags
There is also an option to filter articles by tag. To access this simply click a tag label next to an article and it will take you to the articles filtered by tag page.
You can find this functionality in
App\Http\Blog\ArticlesTagsController.php
.
public function index(Tag $tag)
{
$articles = \App\Article::published()->publishedUntilToday()->tag($tag->id)->paginate(10);
return view('blog.articles_tag', compact(['articles', 'tag']));
}
The
Resources\Views\Blog\Articles_category.blade.php
gets and shows the articles that have a specified tag.
<div class="row">
<div class="col-md-10 ml-auto mr-auto">
<h2 class="card-title">{{ __('Articles by') }}<span style="background-color: {{ $tag->color }}; margin-left: 20px;" class="btn btn-round">{{ $tag->name }}</span></h2>
@include('blog._partials.article_full')
@include('blog._partials.pagination')
</div>
</div>