phoenix-lib / nova-nested-tree-attach-many

MIT License
35 stars 14 forks source link

Translatable Fields #1

Closed iveliniliev90 closed 3 years ago

iveliniliev90 commented 3 years ago

HelloI have an issue where I am trying to attach records where the 'name' for each record is a translatable field (I'm using spatie/laravel-translatable and optimistdigital/nova-translatable ).

And when the records are displayed.. i see only undefined, undefined, undefined image_2020_12_02T13_31_31_475Z

Can you fix this please :)

phoenix-lib commented 3 years ago

Hello! can you provide some code where I can see how you use my package. Today I`m tried to reproduce this problem.

iveliniliev90 commented 3 years ago

Hello! This is my code Category model - image

And your package - image

iveliniliev90 commented 3 years ago

Maybe the problem is here image

phoenix-lib commented 3 years ago

As a temporary solution you can add to your model:

public function toArray(){ return array_merge(parent::toArray(),[ 'translated_name' => $this->name]); }

and when make field provide this field to method withLabelKey.

NestedTreeAttachManyField::make(__('OFFER_CATEGORIES'),'categories','App\Nova\Category') ->withLabelKey('translated_name')

To Fix this error I need change the tree build algorithm.

iveliniliev90 commented 3 years ago

Thank you. This fix my problem!