Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support for polymorphic relations #81

Merged
merged 1 commit into from
Jun 9, 2020
Merged

Conversation

mr-feek
Copy link
Collaborator

@mr-feek mr-feek commented Jun 9, 2020

Basic support for polymorphic relations, should close #80 cc @brendt

It isn't smart enough to figure out MorphTo models, I'm just leaving that as mixed for now. Feel free to pr that functionality!

@mr-feek mr-feek force-pushed the polymorphic-support branch from d9c5330 to da0415a Compare June 9, 2020 17:16
@mr-feek mr-feek merged commit 6d863cd into master Jun 9, 2020
@mr-feek mr-feek deleted the polymorphic-support branch June 9, 2020 17:43
@brendt
Copy link
Contributor

brendt commented Jun 10, 2020

Thanks! It seems to have fixed one of the errors I encountered, but these other three still exist:

ERROR: TooManyTemplateParams - app/Context/Product/Models/Concerns/HasProductAttributes.php:12:16 - Illuminate\Database\Eloquent\Relations\MorphToMany<App\Context\Product\Models\ProductAttribute> has too many template params, expecting 0 (see https://psalm.dev/184)
        return $this->morphToMany(
            ProductAttribute::class,
            'assigned_attribute',
            'product_assigned_attributes',
            'assigned_attribute_uuid'
        );


ERROR: TooManyTemplateParams - app/Context/Product/Models/FieldOfStudy.php:26:16 - Illuminate\Database\Eloquent\Relations\MorphToMany<App\Context\Product\Types\Event\Models\Event> has too many template params, expecting 0 (see https://psalm.dev/184)
        return $this->morphedByMany(Event::class, 'product');


ERROR: TooManyTemplateParams - app/Context/Product/Models/ProductAttribute.php:23:16 - Illuminate\Database\Eloquent\Relations\MorphToMany<App\Context\Product\Types\Event\Models\Event> has too many template params, expecting 0 (see https://psalm.dev/184)
        return $this->morphedByMany(
            Event::class,
            'assigned_attribute',
            'product_assigned_attributes'
        );

@brendt
Copy link
Contributor

brendt commented Jun 10, 2020

Let me know if you need a more comprehensive code snippet.

@mr-feek
Copy link
Collaborator Author

mr-feek commented Jun 10, 2020

Ah I forgot MorphToMany, gimme a few mins to push up a fix!

@mr-feek mr-feek mentioned this pull request Jun 10, 2020
@njaremko
Copy link

This is missing MorphOne support too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for polymorphic relations
3 participants