In this episode, we build on the mentioned functionality we set up previously by adding a new "mentioned" filter to our discussions list. The goal is to let users easily see all discussions where they've been mentioned in any of the posts.
We start by creating a custom query filter for mentions, setting up the basic structure in our code. Then, we hook this filter into our forum index controller and navigation so that it appears as an option alongside other filters for authenticated users.
Next, we get into the logic: using nested whereHas
conditions, we filter discussions to only show those where, within any post, the current user has been mentioned. After setting up the filtering logic, we test it out by selecting the mentioned filter and confirming that it works—showing discussions where we've been tagged.
By the end of the episode, you'll have a working mentioned filter in your discussions app, making it super easy for users to find posts and discussions that are relevant to them!