topclaudy / compoships

Multi-columns relationships for Laravel's Eloquent ORM
MIT License
1.12k stars 130 forks source link

Allow nullable columns #81

Closed ChristopheB closed 4 years ago

ChristopheB commented 4 years ago

Please see #80.

I created a new User model in tests in order to have a real foreign key, so that I could test the usefulness of this line $this->query->whereNotNull($fullKey); in HasOneOrMany (see testARelationshipWithAForeignKeyIsEmptyOnANewInstance).

I also ended up locking down the belongsTo relationship with only null values. in order to have a consistent behaviour with the opposite hasMany (see testARelationshipWithOnlyNullValuesIsNotSupported). Not sure about that though, let me know what you think.

Any comment or suggestion appreciated!

topclaudy commented 4 years ago

@ChristopheB Thanks for the contribution. Can you please update the README to explain this behaviour for the upcoming 2.0?