> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lunarphp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Extending Resources

> How to extend Filament resources in the Lunar admin panel.

Resource extensions allow modifying the form, table, relations, pages, and sub-navigation of any Lunar admin resource. Create a class that extends `ResourceExtension` and register it with the `LunarPanel` facade.

## Example

The following example extends the `ProductResource` to add a custom column to the form and table, a custom relation manager, and additional pages:

```php theme={null}
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Lunar\Admin\Support\Extending\ResourceExtension;

class MyProductResourceExtension extends ResourceExtension
{
    public function extendForm(Form $form): Form
    {
        return $form->schema([
            ...$form->getComponents(withHidden: true),
            TextInput::make('custom_column'),
        ]);
    }

    public function extendTable(Table $table): Table
    {
        return $table->columns([
            ...$table->getColumns(),
            TextColumn::make('product_code'),
        ]);
    }

    public function getRelations(array $managers): array
    {
        return [
            ...$managers,
            MyCustomProductRelationManager::class,
        ];
    }

    public function extendPages(array $pages): array
    {
        return [
            ...$pages,
            'my-page-route-name' => MyPage::route('/{record}/my-page'),
        ];
    }

    public function extendSubNavigation(array $nav): array
    {
        return [
            ...$nav,
            MyPage::class,
        ];
    }
}

// Typically placed in a service provider...
LunarPanel::extensions([
    \Lunar\Admin\Filament\Resources\ProductResource::class => MyProductResourceExtension::class,
]);
```

## Available Methods

| Method | Description |
| :- | :- |
| `extendForm(Form $form)` | Modify the resource's form schema. |
| `extendTable(Table $table)` | Modify the resource's table columns and configuration. |
| `getRelations(array $managers)` | Add or modify relation managers for the resource. |
| `extendPages(array $pages)` | Add custom pages to the resource. |
| `extendSubNavigation(array $nav)` | Add items to the resource's sub-navigation. |
| `headerActions(array $actions)` | Add or modify header actions. |

See the [Filament documentation](https://filamentphp.com/docs) for more details on building resources, relation managers, and pages.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.