Open spawnia opened 6 years ago
@enzonotario have you started work on @morphOne
and @morphMany
? I would like to get those in before the next release.
not yet, but I can work on that this weekend!
I would like to get the Roles of my UserModel, im using spatie/laravel-permissions. It's adding a roles() method with return MorphToMany. How would you guys put the reverse into the Schema - morphedByMany as inverse ? Documentation does not show this directive, but there is a Model in the Tests using morphedByMany here: https://github.com/nuwave/lighthouse/blob/36552f2886296d0e324c3482b5cef155a53b9501/tests/Utils/Models/Tag.php
Any clue ? When @morphedByMany implementation ?
Could you try @belongsToMany
? It works somehow, however I didn't look into the code, so don't know how it exactly works.
You can currently fetch the data also without directive, but you will not have performance benefits from data loaders, as every field will be resolved separately, means every time laravel goes to DB.
Sounds like a workaround, would be amazing to get this fixed / implemented :-)
Is your feature request related to a problem? Please describe.
Many users have come up with use cases where they require some of the other relationship types of Eloquent, such as Polymorphic relationships or Pivot Relations. In many cases, they work fine without any directives or do also work when using
@belongsTo
or@hasMany
, although edge cases do come up from time to time.To clarify: Other relationship types still work without those directives. They can simply be declared as fields on the type without using any directives.
Describe the solution you'd like
Implement additional directives for Eloquent's other relationship types. I am sure we can do some nice optimizations and make Lighthouse even more simple to use.
https://laravel.com/docs/eloquent-relationships#defining-relationships
Support