Closed axit-joost closed 4 years ago
Thanks for reporting this. I agree with this change.
Should be able to add an if
check around this line to see if the data type is id
. If so, generate the factory
call using the column prefix or supplied reference.
You want to try and open a PR for it?
Sure. I'll try and find a time tonight, see if I can cook something up.
As per the Laravel documentation located at https://laravel.com/docs/master/database-testing#relationships, paragraph "Relations & Attribute Closures".
Given the following
draft.yaml
, modelled after a schema.org/Person:The generated factories will currently insert a
$faker->randomDigitNotNull
, like so:As per the documentation, it could be generated like so:
Subsequently, the other
PostalAddressFactory
could be like so:The benefit of this, is that when using the PersonFactory in a test, you will get a Person with a full set of related data:
could yield: