laravel-json-api / eloquent

Serialize Eloquent models to JSON API resources
MIT License
12 stars 15 forks source link

added the ability to use resolveRelationUsing and still use the package #36

Closed danilogiacomi closed 2 months ago

danilogiacomi commented 2 months ago

If you add a relation to a model via the Model::resolveRelationUsing() method (https://laravel.com/docs/11.x/eloquent-relationships#dynamic-relationships) the getRelation() methods in QueryToMany, QueryToOne, HasMany, HasOne, BelongsTo and BelongsToMany don't recognize it as they use method_exists to check if it's available, whereas the relations created this way are only available to the instance and when checked with relationResolver.

Added the checks with relationResolver to all the relevant places

lindyhopchris commented 2 months ago

Thank you for the PR! Tagged as v4.1.0.