get Unique Visitors
Closed this issue · 2 comments
mohammad76 commented
how can I get Unique Visitors count of a model ?
khanzadimahdi commented
unique users can be counted by their IP and by model.
// by ip
$count = Visit::distinct('ip')->count('ip');
// by user's model
$count = Visit::visitor()->count();
accoustick commented
Hi,
I just put this code to my controller, I had change Visit into my model.
$count = Visit::distinct('ip')->count('ip');
the models already use
use Shetabit\Visitor\Traits\Visitable;
and
use Visitable;
then I get this error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ip' in 'field list' (SQL: select count(distinct ip
) as aggregate from 'mymodel' where 'pages'.'deleted_at' is null)