rmsramos/activitylog

Route not defined after extending the resource

quasiperfect opened this issue · 1 comments

Package Version

v1.0.6

Laravel Version

v11.25.0

PHP Version

PHP 8.2.1.7

Problem description

Hi,

Thanks for your work.

I tried to use your plugin and is working great, the only problem i have is when i tried to integrate it better with my app

I have extended the resource and modified the config to use my resource and now i get the error Route [filament.admin.resources.activitylogs.index] not defined.

I cleared all cache

Do you have any idea what i'm doing wrong ?

Expected behavior

I expect the routes to work

Steps to reproduce

Create a new resource app\Filament\Resources\MyActivitylogResource.php

<?php

namespace App\Filament\Resources;

use Rmsramos\Activitylog\Resources\ActivitylogResource;

class MyActivitylogResource extends ActivitylogResource
{
    public static function getModelLabel(): string
    {
        return __('logs.log.model.label');
    }

    public static function getPluralModelLabel(): string
    {
        return __('logs.log.model.plural_label');
    }

    public static function getNavigationIcon(): string
    {
        return '';
    }

    public static function getNavigationLabel(): string
    {
        return __('logs.log.navigation.label');
    }

    public static function getNavigationSort(): ?int
    {
        return 1;
    }

    public static function getNavigationGroup(): ?string
    {
        return __('logs.navigation.group.label');
    }
}

edit the config file config\filament-activitylog.php

<?php

use App\Filament\Resources\MyActivitylogResource;

return [
    'resources' => [
        'label'                  => 'Activity Log',
        'plural_label'           => 'Activity Logs',
        'navigation_group'       => null,
        'navigation_icon'        => '',
        'navigation_sort'        => null,
        'default_sort_column'    => 'id',
        'default_sort_direction' => 'desc',
        'navigation_count_badge' => true,
        'resource'               => MyActivitylogResource::class,
    ],
    'datetime_format' => 'd/m/Y H:i:s',
];

Reproduction repository (issue will be closed if this is not valid)

https://github.com

Relevant log output

No response

I also encountered this. For temporary fix, on your MyActivitylogResource.php simply add:

protected static ?string $slug = 'activitylogs';

Seems like we can only use /admin/activitylogs as the resource endpoint at the moment