8 months ago

Check for unread messages in service provider OR ajax request?

Posted 8 months ago by Azoruk

Imagine you have a private message system. You want to run code that regularly checks if the current auth user has any new message with unread set to true.

Where are you putting this code?

Maybe adding a check in AppServiceProvider when loading partial view with your navbar (editing boot method) and just return all messages that are new to that partial view?

Or maybe that's too many queries.

Maybe make it an ajax request that runs on every page load, but add a cookie that makes it so that the ajax request only runs if it hasn't been run in over 2 minutes.


Please sign in or create an account to participate in this conversation.