sakanjo / filament-fakefill-action
A filament action to fill the form with fake data.
Fund package maintenance!
sakanjo
Requires
- php: ^8.2
- filament/filament: ^3.2
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.1
- orchestra/testbench: ^9.0
- pestphp/pest: ^2.3
- pestphp/pest-plugin-livewire: ^2.1
- phpstan/phpstan: ^1.1
This package is auto-updated.
Last update: 2024-10-20 19:46:16 UTC
README
A Filament action to fake fill the form state.
⨠Help support the maintenance of this package by sponsoring me.
Table of Contents
đĻ Install
composer require sakanjo/filament-fakefill-action
đĻ Usage
On the create page
<?php namespace App\Filament\Admin\Resources\UserResource\Pages; use App\Filament\Admin\Resources\UserResource; use Filament\Resources\Pages\CreateRecord; use SaKanjo\FilamentFakeFillAction\Actions\FakeFillAction; class CreateUser extends CreateRecord { protected static string $resource = UserResource::class; protected function getHeaderActions(): array { return [ FakeFillAction::make(), ]; } }
On the edit page
<?php namespace App\Filament\Admin\Resources\UserResource\Pages; use App\Filament\Admin\Resources\UserResource; use App\Filament\Base\Pages\EditRecord; use SaKanjo\FilamentFakeFillAction\Actions\FakeFillAction; class EditUser extends EditRecord { protected static string $resource = UserResource::class; protected function getHeaderActions(): array { return [ FakeFillAction::make(), ]; } }
Functions
isFakeFilling
<?php namespace Database\Factories; use App\Models\Address; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; use function SaKanjo\FilamentFakeFillAction\isFakeFilling; class UserFactory extends Factory { public function definition(): array { return [ 'name' => isFakeFilling() ? 'Name set from factory' : fake()->name(), 'email' => fake()->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => Hash::make('password'), 'remember_token' => Str::random(10), 'address_id' => isFakeFilling() ? Address::query()->inRandomOrder()->first()->getKey() : null, ]; } }
đ Support the development
Do you like this project? Support it by donating
Click the "đ Sponsor" at the top of this repo.
Šī¸ Credits
đ License
MIT License Š 2023-PRESENT Salah Kanjo