Skip to main content

View Pages: Custom Page or Infolist Builder

Premium
3:53

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 of our courses? (30 h 09 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

E
ElleDinn ✓ Link copied!

First of all, am just starting to learn laravel, i just follow this course,

To view Users i run command below, so happen that Filamentphp I think conflicted the file i created. then I deleted it.

php artisan make:filament-page ViewUsers --resource=UserResource --type=ViewUsers php artisan make:filament-resource UserResource --view

Nowi can no longer access my dashboard. 403 FORBIDDEN. Appologize, i did everything to resolve but nothing happen.

I also have app\Models\User.php

public function canAccessPanel(Panel $panel): bool
{
return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail();
}

}

need help brothers.

PK
Povilas Korop ✓ Link copied!

With canAccessPanel(), are you sure both conditions are true with your logged in user?

  1. Is your domain exactly "@yourdomain.com"?
  2. Is your email verified? It's in users.email_verified_at column in the DB.
E
ElleDinn ✓ Link copied!

Thanks bruh, I'll try to work on it, the workaround i did; installed new installation instead.

A
arminrauscher ✓ Link copied!

is it possible to render stats, widgets and filament table (specific data restricted with a where clause) inside the infolist, or do i need to make a complete separate view page?

J
Joe ✓ Link copied!

It's probably worth pointing out that in order for the Infolist to work while following this tutorial, it's also necessary to remove the protected static string $view = 'filament.resources.products.pages.view-product'; from app/Filament/Resources/ProductResource/Pages/ViewProduct.php

MT
Marcelo Tonon Chiovatto ✓ Link copied!

I have created a Filament Page completely outside of Filament Resources. It is living at App\Filament\Pages (class) and Resources\views\Filament\Pages (blade).

Just to understand how it works, I've built a Filament form in this page to do a dinamic Product Price Calculator.

Everything is working fine, but I don't know how I should route to this Filament page and send parameters via request.

Could you please help?

P.S.: Nowadays I can reach the page because it is appearing in the left menu, but I don't know how to access it via browser URL sending parameters.

M
Modestas ✓ Link copied!

Not sure if I fully understood the question, but you can always use:

Page::getUrl() and this function accepts array of parameters as first value. This way you can link it with whichever request parameters you need

P
Paul ✓ Link copied!

Thanks for this explanation. Now I get an overlay containing data from the database with json. Now I want this overlay to display a table within the infolist builder. Is this possible? In short, I want to use a table within the Infolist.

AU
Artem Ushakov ✓ Link copied!

Is it just me or Filament seems a lot more like Flutter code, not PHP with all these deep infinite nesting? 🤔

M
Modestas ✓ Link copied!

It's a mix for sure! But Filament really well manages the whole OOP principle - everything is a class/object and you are building things like that

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.