Factory call changed
In Laravel 8.x, the style of factory call was changed from helper to static method.
//Laravel 7.x or earlier
factory(User::class)->make()
//Laravel 8.x
User::factory()->make()
It takes plenty of times to fetch this change into your application if you do by yourself.
Don't worry. I made a package to refactor all of them with Just One Command.
Laravel-Factory-Refactor
https://packagist.org/packages/wadakatu/laravel-factory-refactor
This package will help you to refactor the style of factory call from helper to static method for Laravel 8.x.
How to Use
1. Installation
You can install the package via composer:
composer require wadakatu/laravel-factory-refactor --dev
2. Run Artisan Command
php artisan refactor:factory
3. Voila, Refactor Completed !
//Before
factory(User::class)->make();
factory(App\Models\User::class)->make();
factory(User::class, 10)->make();
factory(App\Models\User::class, 10)->make();
//After
User::factory()->make();
App\Models\User::factory()->make();
User::factory()->count(10)->make();
App\Models\User::factory()->count(10)->make();
In conclusion
'Laravel-Factory-Refactor' is my first package ever in my life.
From now on, I am going to do my best to update this package to make it better.
I hope you are going to like it.
Moreover, I am looking forward to getting stars in Github⭐️
https://github.com/wadakatu/laravel-factory-refactor
Thank you.
Top comments (0)