PHP code example of quix-labs / filament-extendable
1. Go to this page and download the library: Download quix-labs/filament-extendable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use QuixLabs\FilamentExtendable\Facades\FilamentExtendable;
class UserResource extends Resource
{
public static function form(Schema $schema): Schema
{
return FilamentExtendable::processSchema($schema, 'user-form');
}
public static function infolist(Schema $schema): Schema
{
return FilamentExtendable::processSchema($schema, 'user-infolist');
}
public static function table(Table $table): Table
{
return FilamentExtendable::processTable($table, 'user-table');
}
}
use QuixLabs\FilamentExtendable\Builders\TableBuilder;
use QuixLabs\FilamentExtendable\Builders\SchemaBuilder;
use QuixLabs\FilamentExtendable\Facades\FilamentExtendable;
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\TextInput;
use Filament\Infolists\Components\TextEntry;
class FilamentExtendServiceProvider extends ServiceProvider
{
public function boot(): void
{
// Insert a column after 'email' in the user table
FilamentExtendable::addTableModifier('user-table', function (TableBuilder $tableBuilder) {
$tableBuilder->insertAfter('email', [
TextColumn::make('lastname')->label('Last Name'),
]);
});
// Add a field to the user infolist
FilamentExtendable::addSchemaModifier('user-infolist', function (SchemaBuilder $schemaBuilder) {
$schemaBuilder->pushComponents([
TextEntry::make('lastname')->label('Last Name'),
]);
});
}
}
// Append at root level (default behavior)
$schemaBuilder->pushComponents([
TextInput::make('nickname')->label('Nickname'),
]);
// After 'bio' at root level
$schemaBuilder->pushComponents([
TextArea::make('additional_notes'),
], position: InsertPosition::AFTER, targetKey: 'bio');
// Before 'email' at root level
$schemaBuilder->pushComponents([
Select::make('preferred_contact_method'),
], position: InsertPosition::BEFORE, targetKey: 'email');
// After 'last_login' in 'tabs.activity' nested tab/section/group/...
$schemaBuilder->pushComponents([
TextEntry::make('last_login_ip')->label('Last Login IP'),
], position: InsertPosition::AFTER, targetKey: 'last_login', targetGroup: 'tabs.activity');
$schemaBuilder->removeComponents([
'email', // Removes 'email' field from the root level
'tabs.seo.meta_title', // Dot notation is supported for nested paths.
]);