laravel-doctrine / fluent

Fluent mapping driver for Doctrine2
http://www.laraveldoctrine.org/docs/current/fluent
MIT License
43 stars 22 forks source link

Null object relationship with builder #56

Closed gmox closed 6 years ago

gmox commented 6 years ago

I have an entity that has an optional relationship, and it's represented in my domain as a Null Object. When the relationship exists and is non-null, this works fine:

$builder->hasOne(Tote::class);

However, when the relationship isn't set, it fails because NullTote (the default value) can't map to Tote.

Is there an easier way of working with null objects in Doctrine's mappings that I'm unaware of? Or is this going to get dirty? I can always try to resolve them (http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/resolve-target-entity-listener.html) but that doesn't really solve my problem.

patrickbrouwers commented 6 years ago

This doesn't sound like a problem with this package? We just provide an fluent syntax to doctrine's mapping api. I think you are better off asking this question on a forum/slack.