From the course: Building a Website with Laravel, React.js, and Inertia

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Displaying posts

Displaying posts

- [Instructor] Now that we have the basic pages done and we have some data in the database, we are going to work on the post controller methods. Let's see how we are going to display the post on the homepage. First of all, the controller. We will render the home component and pass in the array of posts already ordered by the created at timestamp. First of all, the index method. We will use Inertia to render the home component and pass an array of all posts already ordered by the created at timestamp. This way, we don't need to order anything on the React site. As we did in our React app, our home component will import post index component that will be responsible for fetching all posts. We need to uncomment the index import and the post component in the body. We also receive the post object from the controller and then pass it down to the post component. Next, we will create a post index component, copy what we had in the React app and paste it here. We will delete a bunch of stuff…

Contents