Certainly! To create a custom full-page view for a relation in Filament 3, you can follow these steps:
-
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 -
Define the Custom Page: In the newly created
CustomRelationPageclass, you can define the layout and content of your custom page. This class will be located inapp/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); } } -
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 -
Define a Custom Route: You need to define a custom route for your custom page. You can do this in the
routes/web.phpfile.use App\Filament\Pages\CustomRelationPage; Route::get('/custom-relation-page/{recordId}', CustomRelationPage::class)->name('custom-relation-page'); -
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.