Courses

Filament 3 From Scratch: Practical Course

View Pages: Custom Page or Infolist Builder

You're reading a FREE PREVIEW of a PREMIUM course.
Summary of this lesson:
- Creating view-only pages
- Using Infolists for data display
- Customizing view layouts
- Managing page actions

Video Version of the Lesson

[Only for premium members]

Link to the repository

[Only for premium members]

Text Version of the Lesson

In addition to typical Edit pages, you may also want View pages, just to show the record data without editing.

You can generate such a View page immediately when creating a Filament Resource with the --view flag:

php artisan make:filament-resource Product --view

But in our case, we haven't generated it at the time. So, we can add that manually now:

php artisan make:filament-page ViewProduct --resource=ProductResource --type=ViewRecord

Then, we need to add it to the list of our pages in the Resource:

app/Filament/Resources/ProductResource.php:

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

Finally, we need to add an Action link to the table: in addition to the Edit/Delete, we will add the View:

app/Filament/Resources/ProductResource.php:

return $table
->columns([
// ...
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])

This is the visual result:

If you click that View link now and add nothing to the code, Filament will automatically try to duplicate the Edit page, just read-only: with all elements non-editable.

But you can customize that View page in a few ways.


Custom View Page

You may create your own Blade file as a...

The full lesson is only for Premium Members.
Want to access all 24 video+text lessons of this course? (2 h 01 min)

You also get:

  • 79 courses
  • Premium tutorials
  • Access to repositories
  • Private Discord