nolanos/laravel-doctrine-factory
Testing publishing webhook
Add support for Laravel 13
Add support for laravel 12
Support laravel-doctrine/orm v3
Removed lockfile
DoctrineFactory()->make() now persists entities.
This let's the creation process simpler as we can assume everything is already persisted and just flush at the end. It should help with cascade issues.
Make sure to ignore uninitialized properties when creating objects.
Fix factories as defaults
The metadata factory wasn't a reliable method of checking if something is an entity. Instead, just blindly attempt to persist.
The metadata factory wasn't a reliable method of checking if something is an entity. Instead, just blindly attempt to persist.
Support passing factories into the create method, even if the relationship doesn't enable cascade persist.
Post::factory()->create([ 'author' => Author::factory()]);
This also means that factories can use factories in the default definition:
class PostFactory extends DoctrineFactory
{
protected $model = Post::class;
public function definition(): array
{
return [
'title' => fake()->name(),
'author' => User::factory(),
];
}
}
Support null parameters to constructor
None
None
count i.e. creating multiple instancesfor support to include
forUser acts as for(User::Factory())None
Overrides the for method so that it can now be used for Doctrine relationships.
It will infer the name of the relationship based on the class name.
Post::factory()->for($user)->create(); // Sets $post->user;
Relationship name can be overriden:
Post::factory()->for($user, 'author')->create(); // Sets $post->author;
Note: Unlike the method it overrides, it does not yet accept a Factory.
How can I help you explore Laravel packages today?