spatie / activitylog

A very simple activity logger to monitor the users of your website or application
https://spatie.be/opensource/laravel
MIT License
582 stars 75 forks source link

Call to undefined method Illuminate\Database\Query\Builder::log() #15

Closed mohammad6006 closed 9 years ago

mohammad6006 commented 9 years ago

in controller

use Spatie\Activitylog\Models\Activity;

$latestActivities = Activity::with('user')->latest()->limit(100)->get(); // this code works

but i can not use this code : Activity::log("You have updated your basic user information");

error : Call to undefined method Illuminate\Database\Query\Builder::log()

when i use Activity; error is . class activity not found or is used i changed use Spatie\Activitylog\Models\Activity as activitymodel not solved my problem

freekmurze commented 9 years ago

If you want to import both the modal and the facade in one class you'll have to use and alias:

use Activity:
use Spatie\Activitylog\Models\Activity as ActivityModel;

in your code:

$latestActivities = ActivityModel::with('user')->latest()->limit(100)->get(); // this code works

Alternatively you could skip the import, but then you'll have to use the full class name:

$latestActivities = \Spatie\Activitylog\Models\Activity::with('user')->latest()->limit(100)->get();
mohammad6006 commented 9 years ago

thank you very much I solved that problem

but why ip address store ::1 in database (I test it in localhost)

freekmurze commented 9 years ago

I believe ::1 is the ipv6 representation of localhost