Last active
June 30, 2025 09:51
-
-
Save iammuttaqi/40af970ed98818fe98179266a1da3ccc to your computer and use it in GitHub Desktop.
filament tips by muttaqi.md
Author
Author
fill with faker data
// AppServiceProvider.php
foreach ([\Filament\Forms\Components\TextInput::class, \Filament\Forms\Components\Textarea::class, \Filament\Forms\Components\RichEditor::class, \Filament\Forms\Components\MarkdownEditor::class] as $component) {
$component::configureUsing(function ($component) {
$component->hintAction(function () use ($component) {
return \Filament\Forms\Components\Actions\Action::make('fill-with-faker')->icon('heroicon-o-sparkles')
->visible(fn ($component) => !app()->isProduction() && !$component->isDisabled())
->action(function () use ($component) {
$content = match (get_class($component)) {
'Filament\Forms\Components\TextInput' => function () use ($component) {
return match ($component->getType()) {
'email' => fake()->safeEmail(),
'number' => fake()->numberBetween(10, 20),
'tel' => fake()->phoneNumber(),
'url' => fake()->url(),
'password' => fake()->password(),
default => fake()->sentence(),
};
},
'Filament\Forms\Components\Textarea' => fake()->realText(500),
'Filament\Forms\Components\RichEditor' => collect(range(1, 10))->map(fn () => '<p><strong>' . fake()->realText(50) . '</strong></p><p>' . fake()->realText(500) . '</p><hr>')->implode(''),
'Filament\Forms\Components\MarkdownEditor' => collect(range(1, 10))->map(fn () => '**' . fake()->realText(50) . "**\n\n" . fake()->realText(500) . "\n\n" . '---')->implode("\n\n"),
default => 'faker data',
};
$component->state($content);
});
});
});
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
format a TextColumn on table: