shetabit / visitor

a laravel package to work with visitors and retrieve their informations
MIT License
532 stars 69 forks source link

How to solve Call to undefined method App\Models\User::online() error #42

Closed Wesley-Sinde closed 2 years ago

Wesley-Sinde commented 2 years ago

Detailed description

I am new to shetabit/visitor, i was trying set it up today to see how good its is. I have a small issue or big, when i want to check users online i get an error.

BadMethodCallException
Call to undefined method App\Models\User::online()

Someone to help what might be the issue here

My environment

Include as many relevant details about the environment you experienced the bug in and how to reproduce it.

khanzadimahdi commented 2 years ago

use the related trait in the user model. see docs.

Van4kk commented 2 years ago

I'm getting the same error, and I'm using the trait.

BadMethodCallException
Call to undefined method App\Models\User::online()

use HasApiTokens, HasFactory, Notifiable, SoftDeletes, Visitable;

khanzadimahdi commented 2 years ago

@Van4kk see the below files:

https://github.com/shetabit/visitor/blob/master/src/Traits/CanVisit.php https://github.com/shetabit/visitor/blob/master/src/Traits/Visitor.php

you should use the shetabit\Visitor\Traits\Visitor trait in the user class.

read the docs before using the package.

Van4kk commented 2 years ago

ight, thanks ❤️