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

Problem with fetching activity log #12

Closed webmastervinay closed 9 years ago

webmastervinay commented 9 years ago

Hello,

I am able to store the activity log without any issue. But when i am trying to fetch it by following lines

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

I am getting issue as below:

Call to undefined method Spatie\Activitylog\ActivitylogSupervisor::with()

Can you please help??

freekmurze commented 9 years ago

You should import the activty-model instead of the facade.

Make sure you have

use Spatie\Activitylog\Models\Activity;

at the top of your file.

webmastervinay commented 9 years ago

Hello,

I am using it in UserController. I put use Spatie\Activitylog\Models\Activity it in very first line and now it is fetching the records in one of the function.

But now the Activity::log('logged out'); which is also in same UserController (logout method) is not working. It shows Call to undefined method Illuminate\Database\Query\Builder::log().

Both are not working in same controller.

freekmurze commented 9 years ago

When importing two objects with the same name from different namespaces you should alias one of the two.

More info: http://php.net/manual/en/language.namespaces.importing.php