In this episode, we jump right into setting up the foundation for managing sites in our application. We start by creating a new Site model along with its migration. Here, we define all the fields we want for a site, such as associating it with a user, storing both the scheme (like HTTP or HTTPS) and domain separately, giving the site an optional title, and including a boolean to track if it's the user's default site. We talk through the reasoning behind each field and run the migration to get our database ready.
Next, we set up the Site model itself, adding the necessary fillable fields and the relationship to the user. Then, we switch over the dashboard route from using a closure to a dedicated controller, so it's easier to pass data (like a site) down to our Vue components via Inertia.
We experiment with sending different pieces of data from the controller to the dashboard—first a simple greeting, and then an entire site object. This shows how data sent from Laravel ends up as props on the Vue component, just like you’d expect with any frontend framework. We demonstrate what it looks like passing a single model vs. an array or collection, and mention that we’ll be using API resources in the future for better structure.
Finally, we update our routes so the dashboard can optionally take a site ID, letting users view different sites. We wrap up the episode ready to handle switching between sites and with all the groundwork laid for our dashboard to display data dynamically.