Displaying All Posts – WordPress-Like Blog Laravel 5.7 and AdminLTE 3 (10)

WordPress-Like Blog Laravel 5.7 and AdminLTE 3 (10) – Displaying All Posts

In the tenth part of creating WordPress-Like Blog using Laravel 5.7 and AdminLTE 3, we will :

  1. Modify sidebar menu
  2. Displaying all posts

Modify Sidebar Menu

Before we start to perform CRUD on the blog posts, let’s modify the sidebar to remove the unnecessary menus. Open resources/views/layouts/sidebar.blade.php and change the codes to the following :

We only need Blog menu at the moment :

Membuat Blog dengan Laravel 5.7 dan AdminLTE 3 (10) – Menampilkan Posts

Next thing we have to do is to create the blogcontroller in backend. Open terminal and type :

Add routes for Backend\BlogController. Open routes/web.php and add another route :

Modify sidebar.blade.php and change these two li’s :

Modify the Backend\BlogController.php to extends from BackendController :

Modify the index() method in Backend\BlogController :

Add new folder ‘backend/blog’ inside resources/views/ directory, and create index.blade.php.

Membuat Blog dengan Laravel 5.7 dan AdminLTE 3 (10) – Menampilkan Posts 2

Move home.blade.php inside views folder to views/backend folder and modify index() method in HomeController.php :

We will add formattedDate() and publicationLabel() method to Post Model :

Modify backend/blog/index.blade.php to the column under category title :

Now we will be able to differentiate between published and unpublished posts :

Membuat Blog dengan Laravel 5.7 dan AdminLTE 3 (10) – Menampilkan Posts 3

Modify card-footer in index.blade.php to add the pagination and limit information :

Membuat Blog dengan Laravel 5.7 dan AdminLTE 3 (10) – Menampilkan Posts 4

Index method for BlogController has finished.

Github Commit.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.