pxlrbt / filament-activity-log

Spatie activity log integration into Filament
MIT License
144 stars 25 forks source link

Related model attributes not showing #40

Closed muhamadariefnugraha closed 1 month ago

muhamadariefnugraha commented 5 months ago

Hi, thanks for the hardwork.

I am currently using this plugin on Filament V.3 I realized that the related model attributes is not showing on the view.

image

The setup from https://spatie.be/docs/laravel-activitylog/v4/advanced-usage/logging-model-events#content-logging-directly-related-model-attributes has been done correctly. Checked on database, it has a value below: image

Is there any setup missing on my side?

pxlrbt commented 5 months ago

No setup missing on your side. I think I just haven't covered that case yet.

future-social commented 1 month ago

No setup missing on your side. I think I just haven't covered that case yet.

Hi, I'd like to know if this issue has not been solved yet?

Szityak commented 1 month ago

If you override the "createFieldLabelMap" function in your own class, it works.

`protected function createFieldLabelMap(): Collection { $originalAttributeNames = parent::createFieldLabelMap();

    $newAttributeNames = collect([
        'name' => 'custom_text',
        'email' => 'custom_text',
    ]);

    return $originalAttributeNames ->merge($newAttributeNames);
}`
future-social commented 1 month ago

@Szityak Thank you for the solution; it worked. However, it only addressed the issue with the field name and didn't resolve the problem of not being able to retrieve the correct value. I discovered that the root cause is because, in Spatie, the attributes of a relation are recorded using dot notation, which causes data_get to fail in retrieving the data. Therefore, I decided to directly use $changes['attributes']['xxx.xxx'].

pxlrbt commented 1 month ago

Should be fixed by #51