This package will help you to refactor the style of factory call from helper to static method for Laravel 8.x, 9.x, 10.x.
With this package, you can save plenty of time and focus on other important things.
You can install the package via composer:
composer require wadakatu/laravel-factory-refactor --dev
To refactor the style of factory call from helper to static method, run the artisan command:
php artisan refactor:factory
By default, all factory call under tests/
directory are the target of refactoring.
If you want to change the target directory, you can do that by using the --dir
option.
php artisan refactor:factory --dir tests/Feature
By default, Tests\\
namespace is the target of refactoring.
If you want to change the target namespace, you can do that by using the --namespace
option.
php artisan refactor:factory --dir app/Models --namespace App\\Models
factory(User::class)->make();
factory(App\Models\User::class)->make();
factory(User::class, 10)->make();
factory(App\Models\User::class, 10)->make();
factory($model)->make();
factory(User::class, $count['user'])->make();
User::factory()->make();
App\Models\User::factory()->make();
User::factory()->count(10)->make();
App\Models\User::factory()->count(10)->make();
$model::factory()->make();
User::factory()->count($count['user'])->make();
The MIT License (MIT). Please see license file for more information.