shetabit/visitor

get Unique Visitors

Closed this issue · 2 comments

how can I get Unique Visitors count of a model ?

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();

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)