smousss / laravel-factorize
Effortlessly generate Laravel factories for all your models using GPT-4!
0.1.3
2023-04-20 09:39 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^9.0|^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
README
Magically add missing Model Factories
Smousss generates missing Model Factories to help you create fake data seeders and write tests at ease. A dream came true for developers inheriting legacy codebases.
namespace Database\Factories; use … class ThreadFactory extends Factory { public function definition() { return [ 'title' => fake()->sentence(), 'slug' => fake()->slug(), 'content' => fake()->paragraph(), ]; } public function withUser(): static { return $this->state(function () { return [ 'user_id' => User::factory(), ]; }); } … }
Installation
Install the package via Composer:
composer require smousss/laravel-factorize
Publish the config file:
php artisan vendor:publish --tag=factorize-config
Usage
- First, generate a secret key on smousss.com.
- Add it to your
SMOUSSS_SECRET_KEY
environment variable. - Then, create a factory for your Post model:
php artisan smousss:factorize App\\Models\\Post
. Or for multiple models:php artisan smousss:factorize App\\Models\\Post App\\Models\\Comment
Credit
Factorize for Laravel has been developed by Benjamin Crozat for Smousss (Twitter).