ActivityLog - EntryModel - multiple-field_type
Created 6 years ago by girvydas

I have a problem while integrating activity-log package (https://github.com/spatie/laravel-activitylog). It is not detecting relationship type changes (then using multiple-field_type) First of all, Streams EntryModel toArray method should return values like parent method (with relationToArray() method). Second problem happens then package is trying to get EntryModel via $this->fresh() method. Right after save, new values are not yet saved. My guess that there is some compatibility problems with Eloquent sync() method line - (https://github.com/anomalylabs/multiple-field_type/blob/61aa6e25c24dde6da5df41942af651abe1195a42/src/MultipleFieldTypeAccessor.php#L48).

Any thoughts how to implement relation changes? 😄

ryanthompson  —  6 years ago

Does the toArray not return ANY relation information?

If you have a repo you would be willing to share - I could look at it. Otherwise I suppose I could install it myself too 😄

Would be nice to see something like this available to Pyro though. Ill check it out.

girvydas  —  6 years ago

toArray does not return any relation. This is why I created PR.

girvydas  —  6 years ago

Simple situation using "spatie/laravel-activitylog": At "Anomaly\UsersModule\User\UserModel" use "LogsActivity" trait and add: protected static $logAttributes = [ 'first_name', 'roles', ]; protected static $logOnlyDirty = true;

After these changes, when updating user entry it logs only first name.

I had quite same problem with other functionality where I wanted to access fresh created entry relationship value, but it was not yet saved, so I had to use queued jobs to solve that problem..

ryanthompson  —  6 years ago

I'll check that out - thanks for the info!