laravel / nova-issues

556 stars 34 forks source link

Unable to load correct Nova Resource with nested resources with same class names #6584

Open gcg opened 4 days ago

gcg commented 4 days ago

Description:

Lets say you have a class with same name as resources in different sub resource namespace/folders (eg: 'App\Nova\Resources\XXX\LogandApp\Nova\Resources\YYY\Log`)

Even though I am explicly setting 3rd param on HasMany with both class

      HasMany::make('Logs', 'logs', Log::class),

and i tried with string

      HasMany::make('Logs', 'logs', 'App\Nova\XXX\Log'),

However, even though the data that log loaded is for the correct eloquent model (since eloquent relationships are not effected the same way nova resources are), the resource is not right so I can only see the matching fields between 2 resources.

crynobone commented 4 days ago

Laravel Nova doesn't support using the same attribute for multiple field such as above as attribute is consider a unique identifier in this case.

gcg commented 4 days ago

Laravel Nova doesn't support using the same attribute for multiple field such as above as attribute is consider a unique identifier in this case.

The field is not multiple, each resource lives their own namespace directory under app/Nova. (XXX model/resource lives in app/models/xxx/XXX and app/models/xxx/log and YYY model lives in its own directory app/models/yyy/yyy and app/models/yyy/log same structure for the nova resources as well. and YYY resource hasmany logs loads the log explicitly, same with XXX.)

So unless you are not talking about system wide uniqueness, it should work since each class has a unique namespace.

crynobone commented 4 days ago

Unable to reproduce the issue, please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)