|
2 | 2 |
|
3 | 3 | `php artisan generate:model-factory` |
4 | 4 |
|
5 | | -This package helps you generate model factories from your existing models / database structure to get started with testing your Laravel application even faster. |
| 5 | +This package will generate [factories](https://laravel.com/docs/master/database-testing#writing-factories) from your existing models so you can get started with testing your Laravel application more quickly. |
6 | 6 |
|
7 | 7 | ### Example output |
8 | 8 |
|
@@ -48,25 +48,24 @@ $factory->define(App\User::class, function (Faker\Generator $faker) { |
48 | 48 | Require this package with composer using the following command: |
49 | 49 |
|
50 | 50 | ```bash |
51 | | -composer require mpociot/laravel-test-factory-helper |
52 | | -``` |
53 | | -Go to your `config/app.php` and add the service provider: |
54 | | - |
55 | | -```php |
56 | | -Mpociot\LaravelTestFactoryHelper\TestFactoryHelperServiceProvider::class |
| 51 | +composer require --dev mpociot/laravel-test-factory-helper |
57 | 52 | ``` |
58 | 53 |
|
59 | 54 | ### Usage |
60 | 55 |
|
61 | | -Just call the artisan command: |
| 56 | +To generate multiple factories at once, run the artisan command: |
62 | 57 |
|
63 | 58 | `php artisan generate:model-factory` |
64 | 59 |
|
65 | | -This command will look for all models in your "app" folder (configurable by using the `--dir` option) and create test factories and save them in your `database/factories/ModelFactory.php`. |
| 60 | +This command will find all models within your application and create test factories. By default, this will not overwrite any existing model factories. You can _force_ overwriting existing model factories by using the `--force` option. |
| 61 | + |
| 62 | +To generate a factory for specific model or models, run the artisan command: |
| 63 | + |
| 64 | +`php artisan generate:model-factory User Team` |
66 | 65 |
|
67 | | -The output filename is also configurable by using the `--filename` option. |
| 66 | +By default, this command will search under the `app` folder for models. If your models are within a different folder, for example `app/Models`, you can specify this using `--dir` option. In this case, run the artisan command: |
68 | 67 |
|
69 | | -By default, the command will only append new models and doesn't modify the existing content of your factories file. To rewrite the file, use the `--reset` option. |
| 68 | +`php artisan generate:model-factory --dir app/Models -- User Team` |
70 | 69 |
|
71 | 70 | ### License |
72 | 71 |
|
|
0 commit comments