Ability to publish model factories #29
chris-ware
started this conversation in
Ideas
Replies: 1 comment
-
Having just tried to set up a factory for a model without publishing it, it appears that the native mechanics of factories expects the namespace to be inside the Database\Factories one, for example Database\Factories\Package\Models. So if they were to be published, they'd have to be published inside that namespace format, where the last bit matches the namespace of any models in your package. Alternatively, as I've done for now, you can autoload the factories, via composer PSR-4 autoloading. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If a package utilising this awesome tools package comes with model factories, having the ability to publish them would be quite beneficial. My only thoughts that may cause issue is where they are placed in a package. Naturally, it'd be assumed that it'd go in the database directory, with migrations, but the caveat here is that they are namespaced. The problem with utilising the namespace however, would be that publishing them would then break them. It could always take the same approach as migrations and just be a stub file, thus failing if someone tries to run Model::factory() on a package model.
I'm happy to try and do a PR and attempt to write a test if agreeable on what method should be used.
Beta Was this translation helpful? Give feedback.
All reactions