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.
Updating a post - Laravel Tutorial
From the course: Building a Website with Laravel, React.js, and Inertia
Updating a post
- [Instructor] Let's add a new functionality and update an existing post. Before we do that, I want to add a couple of buttons to show under each post, one to update a post and one to delete a post. The update button will take us to a form where the field's populated with existing content. In the post index component, let's add these buttons just under the post body. To edit an existing post, we need to use React Link component to take us to the post update component. (mouse clicks) We are using Link's to prop, which specifies the target URL to navigate to when the link is clicked. In this case, it uses template literal to create a dynamic URL. As for the state prop, this is used to pass the state data to the Link component. In this case, the state being passed is the entire post object. If we check out a browser, we now have two buttons showing under each post. Let's now add a new route in the upload jsx file and create the Posts/Update component. I will paste in the code and we will…
Contents
-
-
-
-
React and Laravel setup3m 32s
-
(Locked)
Creating the Home and About pages1m 52s
-
(Locked)
Creating website navigation3m 24s
-
(Locked)
Displaying posts on a website2m 10s
-
(Locked)
Refactoring to components1m 52s
-
(Locked)
Fetching posts from Laravel API2m 22s
-
(Locked)
Creating a new post3m 43s
-
(Locked)
Updating a post2m 40s
-
(Locked)
Deleting a post1m 42s
-
(Locked)
Challenge: Show individual post page56s
-
(Locked)
Solution: Show individual post page2m 4s
-
-
-