kongulov / nova-tab-translatable

This package contains a NovaTabTranslatable class you can use to make any Nova field type translatable with tabs.
MIT License
79 stars 17 forks source link

External package #20

Closed kamrangaravaliyev closed 2 years ago

kamrangaravaliyev commented 2 years ago

Hi, I tried to use it with SimpleRepeatable. i am getting error. Kongulov\NovaTabTranslatable\NovaTabTranslatable::Kongulov\NovaTabTranslatable{closure}(): Argument #2 ($model) must be of type Illuminate\Database\Eloquent\Model, null given {"userId":1,"exception":" [object] (TypeError(code: 0): Kongulov\NovaTabTranslatable\NovaTabTranslatable::Kongulov\NovaTabTranslatable\{closure}(): Argument #2 ($model) must be of type Illuminate\Database\Eloquent \Model, null given at /var/www/vendor/kongulov/nova-tab-translatable/src/NovaTabTranslatable.php:118)

kongulov commented 2 years ago

@kamrangaravaliyev Hi,

What is your nova version?

kamrangaravaliyev commented 2 years ago

Nova version 3

kongulov commented 2 years ago

@kamrangaravaliyev May I know what version of the tab package you have installed?

Do you mean this SimpleRepeatable package? https://packagist.org/packages/optimistdigital/nova-simple-repeatable

Can you send an example of your code using these 2 packages?

kamrangaravaliyev commented 2 years ago

yes. Laravel Nova version. 3.32.0 "outl1ne/nova-simple-repeatable": "1.4.3", "kongulov/nova-tab-translatable": "^1.1",

kongulov commented 2 years ago

@kamrangaravaliyev

I don't see any problem with myself. Could you send me an example of your code so that I can simulate the error you made?

image image

kamrangaravaliyev commented 2 years ago

SimpleRepeatable::make('Days', 'days', [ NovaTabTranslatable::make([ Text::make("Name", 'name')->rules('required_lang:az'), Trix::make("Description")->rules('required_lang:az') ]), ])->addRowLabel("Gün əlavə et")

This is the code. Unfortunately it doesn't work

kongulov commented 2 years ago

@kamrangaravaliyev

The "NovaTabTranslatable" package works together with the "spatie/laravel-translatable" package where you must specify the "name" field in the model with the translatable $translatable=['name']; But such a structure will not work with the "SimpleRepeatable" package, so wrapping the "NovaTabTranslatable" package in "SimpleRepeatable" will not work.

But if you wrap "SimpleRepeatable" in "NovaTabTranslatable" then everything will work

NovaTabTranslatable::make([
    SimpleRepeatable::make('Name', 'name', [
        Text::make('Name1'),
        Text::make('Name2'),
    ])
    ->canAddRows(true) // Optional, true by default
    ->canDeleteRows(true), // Optional, true by default
])