In this episode, we start things off by creating a brand new Laravel project with user mentions in mind. The first step is ensuring our users have unique usernames, which will be key for mentioning them later, just like you would mention users in GitHub issues or comments.
We set up the project using the Laravel Breeze starter kit and opt for Livewire (but you could adapt this for other frontends too). We walk through the project creation process, pick MySQL for the database, and run our migrations to set up the necessary tables. Then, we create a migration to add a username
column to the users table, making sure it’s unique, update the model to allow mass assignment of this new field, and tweak the user registration process to let new users set their username.
After confirming usernames are stored properly, we also improve the user experience by enabling usernames to be updated from the profile page. We take special care so that users can’t take someone else’s username and that they can keep their own. We also test what happens when trying to pick a duplicate username to make sure our validation is solid.
By the end of this episode, you’ll have a fresh Laravel app where users can register and update their usernames, making your app ready to handle mentions! In the next episode, we’ll dive into building a simple comment system that can detect and handle those username mentions.