How FilamentPHP Naming Resources and How to Get URL

Süleyman Özgür Özarpacı - May 21 '23 - - Dev Community

In FilamentPHP, resources are associated with pages. By default, these pages are named using the format filament.resources.[RESOURCE_PLURAL_NAME].[PAGE_NAME]. For instance, the index page of a ProductResource would be filament.resources.products.index.

To generate a URL, you can utilize the route helper as follows:

route('filament.resources.products.index')
Enter fullscreen mode Exit fullscreen mode

However, I would recommend using the approach preferred by FilamentPHP, which is:

ProductResource::getUrl('edit', ['record' => $record])
Enter fullscreen mode Exit fullscreen mode

This ensures consistency with FilamentPHP's conventions.

Let's make an "Go To Product" action button with this:

Tables\Actions\Action::make('go_to_product')
    ->icon('heroicon-o-pencil-alt')
    ->url(fn (Model $record): string => ProductResource::getUrl('edit', ['record' => $record])),
Enter fullscreen mode Exit fullscreen mode

This button will be redirect user to product's edit page.

. . . . . . . . . . . . . .
Terabox Video Player