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

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