Route with custom location of user resource edit is not defined
iniznet opened this issue · comments
Hi there,
I got an issue where if you move the default user model into another directory it will result in the Route [filament.admin.resources.users.edit] not defined.
error.
After digging into the package, I found that that the issue lies in the file vendor\tapp\filament-authentication-log\src\Resources\AuthenticationLogResource.php
, particularly at line 77. The code at this line only extracts the class name without considering the model's location. Consequently, this approach generates an incorrect route.
In my project, I moved both the user model and the Filament user resource to the Management directory, assigning the namespaces as follows: App\Models\Management
and App\Filament\Resources\Management
.
Temporary Workaround:
use App\Models\Management\User;
class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static ?string $slug = 'users'; // remove 'management' from the slug
...
A possible fix for this issue:
- Take anything after Models
- Replace the remaining slashes with a dot
- Do the original string manipulation
$https://github.com/TappNetwork/filament-authentication-log/issues/%3C/span%3E" target="_blank" rel="nofollowauthenticatable = Str::replace('\\', '.', Str::after($record->authenticatable::class, 'Models\\'));
$authenticatable = Str::plural(Str::lower($authenticatable));
return new HtmlString('<a href="'.route('filament.admin.resources.'.$authenticatable.'.edit', ['record' => $record->authenticatable_id]).'" class="inline-flex items-center justify-center text-sm font-medium hover:underline focus:outline-none focus:underline filament-tables-link text-primary-600 hover:text-primary-500 filament-tables-link-action">'.class_basename($record->authenticatable::class).'</a>');
I'm getting the same error, but appears it's from changing the 'id' of the panel away from admin. I am working on a PR to add a new config item for the panel_id that will bypass this issue