Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

FrazeColder's avatar

Laravel: Spatie Activity Log / Show causer in timeline FilamentPHP

I'm using the Activitylog Pro package (link) and running into an issue with displaying log details in my FilamentPHP OrderResource.

Context

  • I have two models: Order and Disapprove.
  • In my OrderResource, I display a timeline of activities.
  • When a customer disapproves an order (which can happen multiple times for custom orders), a log entry is created.
  • My goal is to show a button which opens a modal with the disapprove reason within this timeline to display the disapprove reason in a modal.

This is my current widget:

Timeline::make('activity')
    ->label('History')
    ->itemActions('disapprove', [
        Forms\Components\Actions\Action::make('disapprove_reason')
            ->label('Disapprove Reason')
            ->modalHeading('Disapprove reason')
            ->modalDescription(fn ($record) => $record->id)
            ->modalSubmitAction(false)
            ->modalCancelActionLabel('Close')
            ->modalCancelAction(),
    ]);

Problem

The $record variable in the modal always refers to the Order model. I need it to reference the specific Disapprove model associated with the log entry.

I store the Disapprove model as the "causer" of the log entry, which might not be the best practice, but it’s what I’m working with. How can I modify the code to achieve this and retrieve the "causer" for each log entry to pass the data to the modal?

As already mentioned, it does not make sense to just retrieve the most recent log entry. This way all buttons/modals would display the most recent disapproval reason and not the one I wanted to open.

Thanks in advance for your help!

0 likes
0 replies

Please or to participate in this conversation.