Skip to content
New issue

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

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

Already on GitHub? # to your account

feat(pivot): add support for multiple pivot types when using the same accessor #1597

Merged
merged 6 commits into from
Oct 28, 2024

Conversation

pataar
Copy link
Contributor

@pataar pataar commented Oct 18, 2024

Summary

Currently, when you have multiple belongsToMany relations with a custom pivot, the accessor will have a single type. This PR ensures that multiple types are allowed. Also the $pivot property should be nullable as it is not always set during runtime.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Misc. change (internal, infrastructure, maintenance, etc.)

Checklist

  • Existing tests have been adapted and/or new tests have been added
  • Add a CHANGELOG.md entry
  • Update the README.md
  • Code style has been fixed via composer fix-style

@pataar pataar marked this pull request as draft October 18, 2024 14:45
@pataar pataar marked this pull request as ready for review October 18, 2024 14:52
@pataar pataar force-pushed the add_support_for_multiple_pivots branch from 5ae9921 to 8c26025 Compare October 18, 2024 14:58
@barryvdh barryvdh merged commit dc70337 into barryvdh:master Oct 28, 2024
16 checks passed
@rpatew2c
Copy link

There's a small issue with the docblocks this PR generates. If the type is already present, it is duplicated. Here is a sample from my codebase running the latest 3.2.1 of ide-helper

- * @property-read \Modules\Contacts\Infrastructure\Models\Phonable|\Modules\Contacts\Infrastructure\Models\Emailable|\Modules\Contacts\Infrastructure\Models\Mailable|null $pivot
+ * @property-read \Modules\Contacts\Infrastructure\Models\Phonable|\Modules\Contacts\Infrastructure\Models\Phonable|\Modules\Contacts\Infrastructure\Models\Emailable|\Modules\Contacts\Infrastructure\Models\Emailable|\Modules\Contacts\Infrastructure\Models\Mailable|\Modules\Contacts\Infrastructure\Models\Mailable|null $pivot

@pataar pataar deleted the add_support_for_multiple_pivots branch October 28, 2024 20:16
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants