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

Trait collision with ConditionalContainer #7

Closed
cord opened this issue Jan 6, 2022 · 4 comments
Closed

Trait collision with ConditionalContainer #7

cord opened this issue Jan 6, 2022 · 4 comments

Comments

@cord
Copy link

cord commented Jan 6, 2022

Great work!

When using together with ConditionalContainer I get following trait collision

Trait method 'availableFields' will not be applied because it collides with 'HasConditionalContainer'

Is there a way to solve this?

@milewski
Copy link
Member

milewski commented Jan 7, 2022

There is no real bullet-proof solution for this yet, laravel nova should do something similar to how eloquent boot traits to be able to stop overriding these methods... but this is an issue that has come up multiple times in other repositories as well.. I think you can follow this workaround it should work:

dcasia/nova-json-wrapper#4 (comment)
dcasia/nova-json-wrapper#10 (comment)

@cord
Copy link
Author

cord commented Jan 7, 2022

wonder if insteadof could be used - but which availableFields is the one which would support both correctly?

https://www.php.net/manual/en/language.oop5.traits.php

    use A, B {
        B::smallTalk insteadof A;
        A::bigTalk insteadof B;
    }

@milewski
Copy link
Member

milewski commented Jan 7, 2022

You need both .. they all call parent::availableFields() thats why extending the class works...

@milewski
Copy link
Member

No longer an issue on the latest version

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

No branches or pull requests

2 participants