Route::filter('before', function() { });
should be a good place.
Pergunta
I have a tiny piece of code on my masterpage in laravel but it is a bit out of place, now I am wondering what is the best place to store this bit of code? It does need to run on every single page though.
<!-- user online-offline script -->
<?php
if(isset($_SERVER["PHP_SELF"])) {
if(Auth::check()) {
$user = User::find(Auth::user()->id);
$user->last_activity = date('Y-m-d H:i:s', time());
$user->save();
}
}
?>
Should I store this in a seperate php file and use an @include on my masterpage for something like this or can I use a different approach with laravel?
Solução
Route::filter('before', function() { });
should be a good place.