Laravel-activitylog: How to log visited Page ?

Created on 10 Oct 2016  路  2Comments  路  Source: spatie/laravel-activitylog

Hello, I tried this package and it works very well !
But i can't find if there is any way to log the visited pages, for example i want to know all the pages visited by one connected user. How can I do this kind of tracking with this package please ???
Thanks :)

Most helpful comment

You could write a middleware that logs activity.

use Closure;

class LogsActivity
{
    public function handle($request, Closure $next)
    {
        if (auth()->check()) {
            activity()
                ->causedBy(auth()->user())
                ->log("User visited {$request->fullUrl()}");
        }

        return $next($request);
    }
}

All 2 comments

You could write a middleware that logs activity.

use Closure;

class LogsActivity
{
    public function handle($request, Closure $next)
    {
        if (auth()->check()) {
            activity()
                ->causedBy(auth()->user())
                ->log("User visited {$request->fullUrl()}");
        }

        return $next($request);
    }
}

It works perfectly ! Thanks, this package is really really useful/powerful !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TheFrankman picture TheFrankman  路  5Comments

DjKhireddine picture DjKhireddine  路  5Comments

uyab picture uyab  路  4Comments

marky291 picture marky291  路  4Comments

ekandreas picture ekandreas  路  3Comments