pxlrbt / filament-activity-log

Spatie activity log integration into Filament
MIT License
126 stars 24 forks source link

Illegal Offset type #19

Closed goldjunge4 closed 10 months ago

goldjunge4 commented 10 months ago

Hello Dennis,

I would like to use your filament package, but have some troubles to get it running. I get always a illegal offset type from the table action and i tried so much different things. Maybe you can give me a hint.

I created a page inside my filament resource folder called "ListStopActivities.php"

<?php

namespace App\Filament\Resources\StopResource\Pages;

use App\Filament\Resources\StopResource;
use pxlrbt\FilamentActivityLog\Pages\ListActivities;

class ListStopActivities extends ListActivities
{
    protected static string $resource = StopResource::class;

}

Afterwards i added the page to the getPages method:

public static function getPages(): array
    {
        return [
            'index' => Pages\ListStops::route('/'),
            'create' => Pages\CreateStop::route('/create'),
            'edit' => Pages\EditStop::route('/{record}/edit'),
            'activities' => Pages\ListStopActivities::route('/{record}/activities'),
        ];
    }

And last i added the action to the table action array.

->actions([
                Tables\Actions\EditAction::make(),
                Tables\Actions\DeleteAction::make(),
                Tables\Actions\Action::make('activities')->url(fn ($record) => StopResource::getUrl('activities', [$record => $record])),
            ])

Maybe you have a hint? Thanks, Armin

pxlrbt commented 10 months ago

I get always a illegal offset type from the table action

Sounds like an issue when rendering the actual changes. Can you share the Flare url of the rror so I can have a look at it?

skurfuerst commented 10 months ago

This is an error in the Table Action array:

WRONG:

                Tables\Actions\Action::make('activities')->url(fn ($record) => StopResource::getUrl('activities', [$record => $record])),

CORRECT:

                Tables\Actions\Action::make('activities')->url(fn ($record) => StopResource::getUrl('activities', ['record' => $record])),

It's a typo in the docs :)

All the best, Sebastian

pxlrbt commented 10 months ago

Thanks @skurfuerst. Took me some time to see the difference, but fixes the readme 😅 @goldjunge4 Does that fix it for you?

pxlrbt commented 10 months ago

Closing due to inactivity