[Eloquent] Allow multiple traits to "extend" methods like getAttribute() #47152
Unanswered
filippotoso
asked this question in
Ideas
Replies: 1 comment 3 replies
-
I don't see how that would work since it would fail before you're even able to call a method. I think the only option you have in this case is to use the See: https://www.php.net/manual/en/language.oop5.traits.php#language.oop5.traits.conflict |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
today I encountered this issue using awobaz/compoships in a model that already used one of my traits. Both overrode the
getAttribute()
method.Trait method getAttribute has not been applied, because there are collisions with other trait methods on App\Models\Ticket
I though this could be elegantly solved implementing a solution in the same way Model::bootTraits() handles traits initialization.
Is this something you'll consider?
Thanks
P.S.
For optimization purposes an array property could be defined to specify which methods can be overwritten.
Beta Was this translation helpful? Give feedback.
All reactions