I am working on Laravel 5.3 and I am looking for some package or some data to make a visit counter for both a web in general, and for every article that contains the site. I'm more interested in each article.
I am working on Laravel 5.3 and I am looking for some package or some data to make a visit counter for both a web in general, and for every article that contains the site. I'm more interested in each article.
You can do it in the following way.
you add use Cache;
Then you will have to add the following in your method.
public function show($id){
$variable = nameModelo::find($id);
if(Cache::has($id)==false){
Cache::add($id,'contador',0.30);
$variable->total_visitas++;
$variable->save();
}
return view('index')->with('variable',$variable);
}
Then you go to your view index or where you put in the view and it would be type
<div aling="center">
{{$variable->total_visitas}}
</div>
This is how I implement it in Laravel 5.1