In this episode, we're setting up the foundation for chat rooms! We start by creating a simple Room
model and migration, giving each room a name and a unique slug for cleaner URLs. Next, we generate a Livewire page component (RoomShow
) to display individual chat rooms, organizing it within a chat/pages
directory to keep things tidy.
We wire up a route in web.php
that uses Laravel's route model binding so we can access rooms via their slug (like /chat/laravel
). We secure this route with authentication middleware, and you can throw in email verification, too, if you’d like.
After running the migration and adding an example room in the database, we connect the page component to the layout provided by Breeze. We then copy over the dashboard template so we don't have to reinvent the wheel, tweak a few things like the room title, and hook up everything so the correct room data displays.
To finish up, we start fleshing out the layout: a grid with a left section reserved for users and the main right section for the chat. We use Tailwind utilities to set their sizes. Finally, while we’re not diving into displaying a list of all chat rooms just yet, that’s easily doable if you want to experiment. By the end, we’ve got access to individual chat rooms, and in the next part, we’ll tackle the chat text area to make the messaging experience smoother.