문제

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?

도움이 되었습니까?

해결책

Route::filter('before', function() { });

should be a good place.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top