PHP code example of shankar / laravel-visit-tracker
1. Go to this page and download the library: Download shankar/laravel-visit-tracker library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shankar / laravel-visit-tracker example snippets
use Shankar\VisitTracker\Traits\TracksVisits;
class Post extends Model
{
use TracksVisits;
}
public function show(Post $post)
{
$post->logVisit();
return view('post.show', compact('post'));
}
Route::get('/my-url', function () {
})->middleware(TrackPageVisit::class);
use Shankar\VisitTracker\Facades\VisitTracker;
use App\Models\Post;
VisitTracker::mostVisitedPages();
VisitTracker::userMostVisitedPages($user);
VisitTracker::globalMostVisitedModels(Post::class);
VisitTracker::userMostVisitedModels($user, Post::class);
VisitTracker::userModelTypeStats($user);
VisitTracker::userAllVisit($user);