In this episode, we dive into setting up the foundation of our app by creating the essential database tables. We'll start by creating the employees
table, which includes columns for their name, a unique slug, and a profile photo URL—plus we'll add a couple of example employees to make things realistic.
Next, we move on to the services
table, setting up things like the service title, a unique slug, the duration (in minutes), and the price (stored in cents to avoid rounding issues). We populate this table with a few example services.
Then comes the fun part: linking employees and services together. Not every employee can perform every service, so we'll set up a many-to-many relationship using a pivot table (employee_service
). Alex can do both "hair" and "hair and beard" services, while Mabel can only do "hair"—just to show how flexible the setup is.
We finish up by defining the model relationships in Laravel, showing you how to easily access which services an employee can perform and vice versa. We also do a quick test by dumping some data in our component to confirm everything is wired up correctly. By the end of the episode, you'll have a solid data structure for employees and services, ready to build on!