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 posts - Laravel Tutorial
From the course: Building a Website with Laravel, React.js, and Inertia
Updating posts
- [Instructor] Let's work on updating an existing post now. We are going to start with the controller and fill out edit and update methods before we move on to the React component. The edit method will write in React component called edit, and we'll pass the post object to the component. In the update method, we'll call the update on the post instance and pass an array of validated data from the request. We will redirect to the homepage again. That's the backend functionality done. So let's work on the front end now. I'm going to create a post edit component and copy paste our create component in to save some time. And for the last time, let's fix it up. First of all, we need to rename the function to edit. Then we need to pass in the post object. Next, we need to prefill the values of author, title, and body with the values for a post object or an empty string if there is no value. And we need to change the use form post property to put. Next, let's update handle submit function. It…
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)
-