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

matissk's avatar

Filament 3 custom view page for relation manager class

Hi,

I searched for a couple of hours and I still can't find information about how to create a custom page view, or just a view page, instead of a model view on a relation in Filament 3. I have created a resource and a relation (table under a resource record), but the only option is to create a modal view. I need a full page view.

Can you help me or at least give me some tips? Can I use infolist() and getPages() methods in a RelationManager? Maybe I need to call some Action class, create a custom view and custom route,or is there a terminal command that allows creating a full page view for a RelationManager?

Thanks!

0 likes
3 replies
LaryAI's avatar
Level 58

Certainly! To create a custom full-page view for a relation in Filament 3, you can follow these steps:

  1. Create a Custom Page Class: First, you need to create a custom page class. You can do this using the Filament command line tool.

    php artisan make:filament-page CustomRelationPage
    
  2. Define the Custom Page: In the newly created CustomRelationPage class, you can define the layout and content of your custom page. This class will be located in app/Filament/Pages/CustomRelationPage.php.

    namespace App\Filament\Pages;
    
    use Filament\Pages\Page;
    
    class CustomRelationPage extends Page
    {
        protected static ?string $navigationIcon = 'heroicon-o-collection';
        protected static string $view = 'filament.pages.custom-relation-page';
    
        public function mount($recordId)
        {
            // Load the related model or any other data you need
            $this->record = YourModel::findOrFail($recordId);
        }
    }
    
  3. Create the Blade View: Create a Blade view file for your custom page. This file should be located at resources/views/filament/pages/custom-relation-page.blade.php.

    @extends('filament::page')
    
    @section('content')
        <div>
            <h1>{{ $record->name }}</h1>
            <!-- Add your custom view content here -->
        </div>
    @endsection
    
  4. Define a Custom Route: You need to define a custom route for your custom page. You can do this in the routes/web.php file.

    use App\Filament\Pages\CustomRelationPage;
    
    Route::get('/custom-relation-page/{recordId}', CustomRelationPage::class)->name('custom-relation-page');
    
  5. Link the Custom Page in Relation Manager: Finally, you need to link this custom page in your RelationManager. You can do this by adding a custom action or button that redirects to your custom page.

    namespace App\Filament\Resources\YourResource\RelationManagers;
    
    use Filament\Resources\RelationManagers\RelationManager;
    use Filament\Tables;
    use Filament\Tables\Actions\Action;
    
    class YourRelationManager extends RelationManager
    {
        protected static string $relationship = 'yourRelation';
    
        public static function table(Table $table): Table
        {
            return $table
                ->columns([
                    // Define your columns here
                ])
                ->actions([
                    Action::make('view')
                        ->label('View')
                        ->url(fn ($record) => route('custom-relation-page', $record->id)),
                ]);
        }
    }
    

By following these steps, you should be able to create a custom full-page view for a relation in Filament 3. This approach allows you to have more control over the layout and content of the page, rather than being limited to a modal view.

anonymouse703's avatar

@jaseofspades88 do you have any ideas sir on how to load/attach custom file in a custom page? it seems that attaching js from the custom page is not working.

my custom blade

if I put console.log in the JS file the log is displayed in the console but other function is not working. Also the second script is not working.

If i put the custom scrip in the AdminPanelProvider.. I have consoles but other functions is not working

If in AdminPanel


        FilamentAsset::register([
            Js::make('video-js', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/video.min.js'),
            Js::make('videojs-contrib-eme', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/videojs-contrib-eme.min.js'),
            Css::make('video-css', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/video-js.min.css'),

            Js::make('pallycon-helper', asset('js/pallycon-helper.js')),
            Js::make('video-player', asset('js/video-display.js')),
        ]);

Please or to participate in this conversation.