-
Notifications
You must be signed in to change notification settings - Fork 10
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 Collisions #10
Comments
Okay you need to do this: 1 - create a php class like this: <?php
declare(strict_types = 1);
namespace App\Nova\Concerns;
use App\Nova\Resource;
abstract class UseConditionalContainer extends Resource
{
use HasConditionalContainer;
} 2 - Create another PHP class that extends the previous one <?php
declare(strict_types = 1);
use App\Nova\Resource;
abstract class UseJsonWraperAndConditionalContainer extends UseConditionalContainer
{
use HasJsonWrapper;
} 3 - Now use the class CaseX extends UseJsonWraperAndConditionalContainer
{
....
} |
@milewski first of all, thank you for your help, I really appreciate it! ⭐⭐⭐⭐⭐ So I did what you recommended, it worked. What happens now, is that when I try to create complex (nested) structures, the conditional container seems to be breaking in the UI when I'm editing a resource. Basically, I'll use a lot of Whether I use multiple If I use the example of https://github.com/dcasia/nova-json-wrapper#notes, I get the same error: Obrigado! |
Uhm I think this bug appeared on the latest version of nova.. when I built this package nova was on version 2.something .. I remember someone mentioning on the issues about it not working on the latest version... meanwhile what I could recommend you to do is not nesting so many JSON Wrappers .. instead, have a single level nesting and add the attributes of your fields with dots.. for example: JsonWrapper::make('shipping', [
Text::make('Field Name', 'field.dot.name')
])->fillUsing(function (){
//Arr::dot()
}) And use the fillUsing option to parse the data which will be using |
There's a better way with trait precedence: use HasConditionalContainer, HasJsonWrapper {
HasConditionalContainer::availablePanelsForDetail insteadof HasJsonWrapper;
HasConditionalContainer::availableFields insteadof HasJsonWrapper;
} |
@Kubitomakita this will make only 1 method of the 2 traits run, in your example, only methods from |
Hi,
I know this issue was addressed in different ways before, but I'm really having troubles and I don't know very much how to solve it.
My stack:
The problem is when I try to use https://github.com/dcasia/conditional-container and https://github.com/dcasia/nova-json-wrapper at the same time.
For both packages, you have to use the traits to have everything working, but when they are used together, we have conflicts:
Then you get this error:
I know it happens because both traits have repeated methods, but I don't know how to exactly solve this issue.
I've been around checking some possible workarounds, and I found some related links, like:
I read the workarounds, but I didn't understand how to create them.
Could anyone with more experience help me to solve this issue?
Thanks!
The text was updated successfully, but these errors were encountered: