-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for factory states [enhancement] #452
Labels
next
Relevant for the next major release
Comments
I'd accept PRs for this, but I'd rather go with |
lucacri
pushed a commit
to lucacri/laravel-apidoc-generator
that referenced
this issue
Feb 4, 2020
I created a MR quest for this! Please let me know if it can be merged |
Will this also be made available to the |
My MR is only for the |
This is now supported in Scribe 🙂. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently if you use
@transformerModel MyModel
tag it will create an instance of model usingfactory(MyModel::class, 1)
This works for most cases, but sometimes we have an endpoint that returns only specific type of models (eg. only admin users or only active products).
Using a different item as example makes no sense, and might even be confusing
(I had an endpoint that only returns one type of banners that had an extra field, but example was missing this field when incorrect type of banner was returned)
My suggestion is to add optional parameters to
@transformerModel
tag that will work as states.So eg.
@transformerModel User admin with_example_password
will use following factory insteadfactory(User::class, 1)->states(['admin', 'with_example_password'])
The text was updated successfully, but these errors were encountered: