Skip to content
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Apr 15, 2020
1 parent 17f3219 commit 425d9b4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 30 deletions.
53 changes: 27 additions & 26 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,34 @@ With `laravel-factory-prefill` you can just skip the previous command call and i
## Usage
After running `php artisan migrate` you are good to go. If you want the `factory:prefill` command to notice the model relations, you should implement the methods first!

`php artisan factory:prefill model_name`

*Tip: If you also want the realtionships to be loaded automatically, you have to define the methods in the models.*

### Models with different namespace
### Fill all Factories
To generate factories for all models run

`php artisan factory:all`

#### Models in different directories
To prefill factories from models outside of the `app/` directory just add the `-P` flag and provide the path.

`php artisan factory:all --path=Some/Other/Path`

you can also append the `--realpath` option to indicate that the given path is a pre-resolved absolut path.

### Fill single Factory
To fill a single factory you can either run `php artisan factory:prefill model_name` or `php artisan factory:all model_name`.

#### Models with different namespace
To prefill factories from models outside of the `App/` namespace just add the `-O` flag and provide the full path in the model name.

`php artisan factory:prefill "Some\Other\Namespace\ModelName" -O`

### Nullable columns
By default `nullable` columns are ignored. If you want to also add `nullable` columns to your factory includ the flag `-N` or `--allow-nullable`.

`php artisan factory:prefill "Some\Other\Namespace\ModelName" -N`
`php artisan factory:prefill ModelName -N`
or
`php artisan factory:all -N`


## Testing
Expand Down

0 comments on commit 425d9b4

Please sign in to comment.