Homepage
Material Blog with Laravel has all the core features you need in a blog, right out of the box:
- A homepage which lists featured and latest articles
- A top authors section
- Articles listed by category, tag or author
- A search results page
- Article page (complete with related articles and a comment section)
The homepage is structured in three sections:
- the featured articles section. Featured articles are selected by the admin from the Material Dashboard admin panel
- a list of the latest articles
- a section with the most popular authors
In the App\Http\HomeController
you can see how data gets added to the page . "published", "publishedUntilToday" and "showHomepage" are local scopes and can be found in Article model. "userIsAuthor"
is also a local scope which can be found in the User model.
public function index()
{
$featured_articles = \App\Article::published()->showHomepage()->publishedUntilToday()->take(4)->get();
$latest_articles = \App\Article::published()->publishedUntilToday()->orderBy('publish_date', 'desc')->take(3)->get();
$authors = \App\User::userIsAuthor()->take(4)->get();
return view('blog.home', compact(['featured_articles', 'latest_articles', 'authors']));
}
The Resources\Views\Blog\Home.blade.php
holds the information about featured articles, latest articles and top authors.
<h2 class="title">{{ __('Featured Articles') }}</h2>
<div class="card card-plain card-blog">
@foreach ($featured_articles as $article)
@include('blog._partials.featured_articles')
@endforeach
</div>
</h2>
<div class="section">
<h2 class="title text-center">{{ __('Latest articles') }}</h2>
<div class="row justify-content-center">
@foreach ($latest_articles as $article)
@include('blog._partials.latest_articles')
@endforeach
<a href="{{ route('blog.article.index') }}" class="btn btn-rose btn-raised btn-round">
{{ __('View All') }}
</a>
</div>
</div>
@include('blog._partials.authors')