In this episode, we build out the product show page for our example product in Laravel. First, we set up the route and controller, using route model binding so that we can easily fetch a product by its slug in the URL (like /products/example-product
). We walk through how Laravel binds models and how to customize it to use a slug instead of the default integer ID.
Next, we create a Blade view for our product, and drop in some sample markup from the course resources so we don't waste time on front-end styling. After making sure our CSS (via Tailwind) is being built correctly, we start displaying basic information—like the product title, description, and image—on the product page.
A big focus of the episode is handling money formatting for the product's price. We use the laravel-money
package, which makes it really easy to format currency properly for display. After installing and setting up the package, we configure our app to use USD, but we talk about how you can easily swap this for another currency globally using the config files. We also add a helper method on the model called formattedPrice
, so our views stay clean and readable.
By the end of this video, your product show page will be displaying all the core information, properly formatted prices, and is ready for us to add more advanced features like image galleries and variation selectors in future episodes.