Hi,
I've just updated from version 1 to the latest.
I used to show users the changes they had made using this:
{{ json_encode($activity->changes, JSON_PRETTY_PRINT) }}
Now, when doing that, I am getting this:
Spatie\Activitylog\Models\Activity::changes must return a relationship instance. (View: /home/vagrant/*****/log/view.blade.php)
Any help is appreciated.
Try this: {{ json_encode($activity->changes(), JSON_PRETTY_PRINT) }}
Hi, i麓m facing a similar problem, $activity->changes returns this error, but $activity->changes() returns nothing.
Hi, i'm having the same issue, $activity->changes() returns empty array. I'm using 2.3 version.
Same error here Spatie\Activitylog\Models\Activity::changes must return a relationship instance..
@denitsa-cm you're probably on v1 of the package.
@freekmurze I'm on
"name": "spatie/laravel-activitylog",
"version": "2.4.1",
$activity->changes() returns the collection for me, instead of just $activity->changes
I also see it in the code https://github.com/spatie/laravel-activitylog/blob/master/src/Models/Activity.php#L46
But I would expect to get the collection from $activity->changes (as an attribute), and $activity->changes() to return a relation, similar to a normal eloquent model, no? Same as $activity->subject would return the attribute, and not $activity->subject().
Currently it is set up so changes is a function, not a property that returns a collection with changes.
I might revise this in a future major version.