From 35f0f1395ef94715fad3fcde00143e8fee195ffb Mon Sep 17 00:00:00 2001 From: Travis Obregon Date: Thu, 21 Oct 2021 14:54:36 +0100 Subject: [PATCH 1/2] Add docs on how to register an action. --- docs/02-resources.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/02-resources.md b/docs/02-resources.md index 1050b9a9d0..6cf1c463e4 100644 --- a/docs/02-resources.md +++ b/docs/02-resources.md @@ -337,6 +337,24 @@ To generate a URL for a resource route, you may call the static `generateUrl()` SortCustomers::generateUrl($parameters = [], $absolute = true); ``` +To access a custom page, such as a "show" route, you may define a new action for each table: + +```php +use Filament\Resources\Tables\Table; +use Filament\Tables\RecordActions\Link; + +public static function table(Table $table) +{ + return $table + // ... + ->prependRecordActions([ + Link::make('view')->url(fn ($record) => static::generateUrl('show', ['record' => $record])), + ]); +} +``` + +By passing a callback to the `url` method, you can get access to each row's record. You may also use the `pushRecordActions` or `recordActions` method to define actions on a `$table`. + ## Authorization For authorization, Filament will observe any [model policies](https://laravel.com/docs/authorization#creating-policies) that are registered in your app. The `viewAny` action may be used to completely disable resources and remove them from the navigation menu. From 4fbd652d1c3652893e462048641728881d2b7db7 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Tue, 2 Nov 2021 15:19:18 +0000 Subject: [PATCH 2/2] Update 02-resources.md --- docs/02-resources.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/02-resources.md b/docs/02-resources.md index 6cf1c463e4..71345e3cfe 100644 --- a/docs/02-resources.md +++ b/docs/02-resources.md @@ -337,7 +337,7 @@ To generate a URL for a resource route, you may call the static `generateUrl()` SortCustomers::generateUrl($parameters = [], $absolute = true); ``` -To access a custom page, such as a "show" route, you may define a new action for each table: +To access a custom page, such as a "show" route, from the table, you can define a new action: ```php use Filament\Resources\Tables\Table; @@ -353,7 +353,7 @@ public static function table(Table $table) } ``` -By passing a callback to the `url` method, you can get access to each row's record. You may also use the `pushRecordActions` or `recordActions` method to define actions on a `$table`. +By passing a callback to the `url()` method, you can get access to each row's record. ## Authorization