Merge pull request #666 from travisobregon/patch-1

Add docs on how to register an action.
This commit is contained in:
Dan Harrin
2021-11-02 15:19:34 +00:00
committed by GitHub
+18
View File
@@ -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, from the table, you can define a new action:
```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.
## 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.