FilamentF
Filament11mo ago
tjodalv

Multiple RelationManager's on custom ManageRelatedRecords page

Hello everyone!

I’m using Spatie Media Library with Filament and want to create a dedicated page to manage product media. My Product model has registered collections: Images and Downloads, but each model can also have its own custom collections.
I attempted to create a MediaManageRelatedRecords page with multiple relation managers—one for each media collection. While I managed to get it working, I encountered an issue: whenever I click on any action in the RelationManager table, I receive an error stating "Unable to find component: [...]".

ProductResource class:

// src/Filament/Resources/ProductResource.php
...
    public static function getRecordSubNavigation(Page $page): array
    {
        return $page->generateNavigationItems([
            // ...
            Pages\EditProduct::class,
            Pages\ManageProductImages::class,
        ]);
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListProducts::route('/'),
            'view' => Pages\ViewProduct::route('/{record}'),
            'edit' => Pages\EditProduct::route('/{record}/edit'),
            'images' => Pages\ManageProductImages::route('/{record}/images'),
        ];
    }


ManageProductImages page class:

// src/Filament/Resources/ProductResource/Pages/ManageProductImages.php
class ManageProductImages extends ManageMediasRelatedRecords
{
    protected static string $resource = ProductResource::class;
}
Was this page helpful?