A set of reusable Filament helpers, columns, fields, actions and more!
You can install the package via composer:
composer require saade/filament-extra
This field lets you render a Relation Manager inside a form. It's useful if you need to render it inside a tab or a modal.
use Saade\FilamentExtra\Forms\Components\RelationManager;
use App\Filament\Resources\YourResource\RelationManagers\YourRelationManager;
RelationManager::make(YourRelationManager::class)
->lazy(bool $lazy = true)
This field lets you pick a Filament color from your application.
use Saade\FilamentExtra\Forms\Components\ColorSelect;
ColorSelect::make('color')
Tired of overriding the getEloquentQuery
method in every resource? This trait will handle soft deletes for you.
use Filament\Resources\Resource;
use Saade\FilamentExtra\Concerns\HasSoftDeletedRecords;
class YourResource extends Resource
{
use HasSoftDeletedRecords;
}
This trait will handle breadcrumbs for you. It's useful if you need to render breadcrumbs for a resource that belongs to a navigation group.
use Filament\Resources\Pages\CreateRecord;
use Saade\FilamentExtra\Concerns\NavigationGroupAwareBreadcrumbs;
class CreateYourRecord extends CreateRecord
{
use NavigationGroupAwareBreadcrumbs;
}
This trait will handle nested resources for you. Read the blog post if you want to know more. This code was partially taken from LaravelDaily/filament-nested-resources and contributed back to the community.
- Add the
$parentResource
property to your child resource.
use Filament\Resources\Resource;
class ChildResource extends Resource
{
public static ?string $parentResource = ParentResource::class;
}
- Add the child resource pages to the parent resource.
use Filament\Resources\Resource;
class ParentResource extends Resource
{
public static function getPages(): array
{
return [
'index' => Pages\ManageParents::route('/'),
'edit' => Pages\EditParent::route('/{record}/edit'),
// Please note that 'child' can be anything you want. It defaults to the resource slug.
// If you want to change it, you need to override the $pageNamePrefix property on the child resource pages.
'child.index' => ChildResource\Pages\ListChildren::route('/{parent}/children'),
'child.create' => ChildResource\Pages\CreateChild::route('{parent}/children/create'),
'child.edit' => ChildResource\Pages\EditChild::route('{parent}/children/{record}/edit'),
];
}
}
- Add the trait to your child resource pages.
use Filament\Resources\Pages\ListRecords;
use Saade\FilamentExtra\Concerns\HasParentResource;
class ListChildren extends ListRecords
{
use HasParentResource;
// (optional) Define custom relationship key (if it does not match the table name pattern).
protected ?string $relationshipKey = 'parent_id';
// (optional) Define custom child page name prefix for child pages (if it does not match the parent resource slug).
protected ?string $pageNamePrefix = 'child';
}
This class helps you interact with Filament colors. It's useful if you need to convert a color to a hex value, pick a shade to collect()
Filament colors.
use Saade\FilamentExtra\Support\Color;
Color::make(name: 'fuchia', shade: 200)
->shade(int $shade = 500) // Set a shade
->get() // Returns the color as array of shades
->toHex() // Returns the color as hex value
->toRgb() // Returns the color as rgb value
->collect() // Returns the color as a Laravel Collection
This function is a shortcut to the Color
class.
use function Saade\FilamentExtra\Support\color;
color(name: 'fuchia', shade: 200)
->shade(int $shade = 500) // Set a shade
->get() // Returns the color as array of shades
->toHex() // Returns the color as hex value
->toRgb() // Returns the color as rgb value
->collect() // Returns the color as a Laravel Collection
Use this function as a shortcut to the Illuminate\Support\HtmlString
class.
use Filament\Forms;
use function Saade\FilamentExtra\Support\html;
Filament\Forms\Components\SomeField::make()
->label(
html('<span class="text-red-500">*</span> Label')
)
Use this function as a shortcut to the Illuminate\Support\HtmlString
class to convert markdown to HtmlString.
use Filament\Forms;
use function Saade\FilamentExtra\Support\md;
Filament\Forms\Components\SomeField::make()
->label(
md('### Label')
)
Use this function to render blade templates.
use Filament\Forms;
use function Saade\FilamentExtra\Support\blade;
Filament\Forms\Components\SomeField::make()
->label(
blade('<x-heroicon::some-icon class="w-5 h-5" /> Label', ['some' => 'data'])
)
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
- Saade
- LaravelDaily For the nested resource implementation.
- All Contributors
The MIT License (MIT). Please see License File for more information.