In this episode, we're refining the friend-adding functionality so things make sense for users. First off, we take care of the weird case where you could add yourself as a friend (yeah, not very social!). We show you how to pop a quick check in the controller to block this from happening and discuss why it’s better to handle these checks at the controller level rather than stuffing them in the model.
After that, we turn to the front-end and make sure the "Add as Friend" button doesn’t even show up when you’re viewing your own profile. It’s one of those little UX improvements that makes the app feel more polished.
Finally, we tackle the situation where you could add someone as a friend multiple times (which would clutter up your friend list with duplicates). We put a check in the controller to prevent duplicate friend entries, no matter which direction the relationship is. We wrap up by talking about how all this logic could be tidied up even more, maybe offloaded into middleware or similar, but for now, our friend system is solid and avoids all the awkward bugs.