noxoua / filament-activity-log

Add-on for simplified activity logging based on spatie package.
http://activity-log.noxo.app/
MIT License
66 stars 14 forks source link

[Bug]: Attaching/detaching records doesn't log the related record fields #74

Open RixzZ opened 6 months ago

RixzZ commented 6 months ago

What happened?

When using Relations Managers and implementing them on the logger as per the documentation, the log only displays an 'Entry attached' messages, but doesn't show the related model fields:

image

How to reproduce the bug

I have an User model and a Permissions model. They are related many-to-many between them and a relation manager is used to attach/detach records.

I added the relation manager to the Logger configuration:

                RelationManager::make('perms')
                    ->fields([
                        Field::make('name'),
                        Field::make('category.name')
                            ->hasOne('category'),
                        Field::make('description'),
                        Field::make('url')
                            ->label('URL'),
                    ]),

But only the 'Entry attached' is displayed in the log, not the fields.

Even on the DB, those fields are not saved:

*************************** 4. row ***************************
          id: 4
    log_name: default
 description: attached
subject_type: App\Models\User
       event: attached
  subject_id: 11
 causer_type: App\Models\User
   causer_id: 11
  properties: {"old":[],"attributes":[],"relation_manager":{"name":"perms","id":8}}
  batch_uuid: NULL
  created_at: 2024-04-29 13:10:22
  updated_at: 2024-04-29 13:10:22

I also have some extra columns in the pivot table that I would like to show here too, but those I don't even know how should be added.

Package Version

2.2.5

PHP Version

8.3.6

Laravel Version

11.5.0

Which operating systems does with happen with?

macOS

Notes

No response