PHP code example of sakanjo / filament-fakefill-action
1. Go to this page and download the library: Download sakanjo/filament-fakefill-action 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/ */
sakanjo / filament-fakefill-action example snippets
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(),
];
}
}
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(),
];
}
}
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,
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.