Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcmatters/laravel-factory-generators
https://github.com/mcmatters/laravel-factory-generators
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/mcmatters/laravel-factory-generators
- Owner: MCMatters
- Created: 2017-05-05T22:20:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-13T20:56:59.000Z (over 4 years ago)
- Last Synced: 2024-08-26T09:04:46.819Z (5 months ago)
- Language: PHP
- Size: 20.5 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Laravel Factory Generators
Generate factories for all non-created factories of models.
### Installation
```bash
composer require mcmatters/laravel-factory-generators
```Include the service provider within your `config/app.php` file.
```php
'providers' => [
McMatters\FactoryGenerators\ServiceProvider::class,
]
```Publish the configuration.
```bash
php artisan vendor:publish --provider="McMatters\FactoryGenerators\ServiceProvider"
```Then open the `config/factory-generators.php` and configure paths where your models are locating.
### Advanced configuration
| Name | Description |
|-----------------------|-------------|
| folders | `models` - path where models are locating
`factories` - path where factories are locating. |
| follow_subdirectories | Enable this option if your models are in subdirectories and you wish to keep the structure of the folders. For example, if your model has next namespace: `App\Models\User\Profile` it will generate in your factories folder subdirectory with name `User` including `ProfileFactory.php` file.
**NOTE:** If you enable this option, please specify the root namespace. |
| model_namespace | Requires only, if you enabled option above. |
| types | An array of custom types for DBAL. For example: `'json' => 'string'`. |
| prefix | Prefix for factory files. |
| suffix | Suffix for factory files. |
| skip_columns | An array of the global column names for skipping, for example, you may wish to skip `created_at` and `updated_at` columns in all models. |
| skip_models | An array of the fully qualified model names for skipping. |
| skip_model_columns | An associative array with skipping columns for specific model. Example: `'App\Models\User' => ['password', 'remember_token']`. |
| align_array_keys | If this option will be enabled, all your factories will include aligned array keys. |## Usage
Just run the command `php artisan factory:generate`.