No matter the page to be viewed, some info about the visitor must be saved before, in my Laravel application. I also do some checking. Now, I do all this in my App::before
filter, being the only place called everytime a page is loaded.
Is this a correct way of doing it or there's a better option? The fact that App::before
filter is the only place where you can add global tasks to be realized before loading any route looks a little bit unusual to me, because saving visitor's data into the database is not exactly a filtering operation
Actually, that would be the most 'correct' method to place it in. I think you're not looking for a way to do something before the View is returned. You're looking for a way to do something before the response is sent. App::before()
would be the correct way of doing that, factoring in that any changes you make should be visible in the view.
If you're really looking to do something before the View is returned, take a look at View Composers.