In this episode, we pull everything together to make our product update process work smoothly! We start by creating a submit method on our edit product component (since it didn't exist yet) and bring over the validation rules from the create product component. But there's a snag: when editing, the product's slug already exists, so our validation would fail. We fix this by changing the validation rules from a property to a method, letting us specify which product to ignore in the uniqueness check.
With validation working, we update the product details using the model's update method. We test it out — change the price, description, or slug — and see the updates reflected right away. Next, we tackle handling files. We handle adding new files much like on product creation, and then handle removing files by detaching them from the product using a simple query based on the files we've marked for removal.
Finally, we try everything out: remove a file, add a new one, update the product, and check the database to see all changes reflected. That's all there is to getting both product details and files updated together in the edit process!