In this episode, we finish up the whole video encoding process by making sure everything is nice and tidy once a video has been processed. After covering uploading files and running encoding jobs, we now focus on cleaning up: deleting the original uploaded file, updating our database record to link to the newly encoded video, and marking it as encoded.
You'll see how to go into the encoding job, delete the old file using Laravel's storage facade, and update your model with the fresh encoded video path and an encoded flag. There's a quick recap on where this logic should live, plus some ideas if you want to broadcast a new event (for example, to update progress on the client side).
Finally, we run through the whole process live: uploading a video, confirming that the old file gets deleted after encoding, and checking that the new encoded file is saved properly. By the end, you'll have a tidy setup where only your final encoded videos remain and your models are all up-to-date—plus you know how to hook in any custom events for the client if you want. We're all set!