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 - Laravel Tutorial
From the course: Building a Website with Laravel, React.js, and Inertia
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
-
-
-
-
-
(Locked)
Introduction to Inertia.js1m 16s
-
(Locked)
Getting started with a new Inertia project1m 58s
-
(Locked)
Creating a Post resource2m 29s
-
(Locked)
Creating the Home and About pages2m 14s
-
Creating an Inertia navigation2m 6s
-
(Locked)
Changing the website title2m 4s
-
(Locked)
Displaying posts3m 4s
-
(Locked)
Creating posts4m 37s
-
(Locked)
Displaying a single post1m 29s
-
(Locked)
Updating posts1m 51s
-
(Locked)
Deleting posts1m 33s
-
(Locked)
Challenge: Show a flash message1m 2s
-
(Locked)
Solution: Show a flash message2m 59s
-
(Locked)
-