Skip to content

[Laravel] Relation methods other than HasMany that return multiple results are not working #6736

@amermchaudhary

Description

@amermchaudhary

API Platform version(s) affected: 3.*, 4.*

Description
If I use a relation other than HasMany that returns multiple items then the API does not work correctly because it tries to return a single item

How to reproduce
use a HasManyThrough, BelongsToMany, MorphMany, or MorphToMany relation

Possible Solution
In src/Laravel/Eloquent/Metadata/Factory/Property/EloquentPropertyMetadataFactory.php#L96
Change this if statement to include other possible relations that return a collection

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions