In this episode, we dive into building the Friends page for our app, making sure it can handle and display all the different friend statuses a user might have. We're talking about: the friends you've sent requests to (pending), the ones who've sent requests to you, and finally, your accepted friends.
We start by creating a quick scaffold for the Friends page interface, just copying over an existing template from our homepage to get things moving quickly. Then, we wire up a controller and set up a route for /friends
, making sure it's only accessible to authenticated users by adding the appropriate middleware.
Before fleshing out the UI, we focus on testing. We write feature tests step by step to ensure each piece of the friend status logic works as expected:
For each of these, we set up some example users, manipulate their friendship statuses, and make sure the correct information appears on the page in the right order. As we pass each test, we update our controller and Blade view to make the tests green.
Once all the tests pass, we add some basic UI polish: showing or hiding each section only if there’s something to show. The episode is both about building out the actual page and making sure every little detail is covered by automated tests. Perfect if you want rock-solid social features in your app!