Reputation: 152
I am new to Laravel 5.
I want to count the number of visitor of my website. I already followed this steps in laravel visitors counter but it did not work.
Is there any other solution for this problem?
Upvotes: 1
Views: 11833
Reputation: 1068
public function post(post $post)
{
$key = 'myblog'.$post->id;
if (!Session::has($key)) {
$post->increment('view_count');
Session::put($key , 1);
}
return view('frontend.post.show',compact('post'));
}
Upvotes: 0
Reputation: 2856
Just use this library it provides lot of option for Tracking
Just install the dependency
composer require pragmarx/tracker
Add the service provider to your app/config/app.php:
'PragmaRX\Tracker\Vendor\Laravel\ServiceProvider',
Add the alias to the facade on your app/config/app.php:
'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade',
Upvotes: 5