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

Problem when add in NovaServiceProvider #6

Open
AnniDineva opened this issue Nov 6, 2023 · 1 comment
Open

Problem when add in NovaServiceProvider #6

AnniDineva opened this issue Nov 6, 2023 · 1 comment

Comments

@AnniDineva
Copy link

Hi, when I add LaravelNovaTranslationEditor in NovaServiceProvider I get this error
"TypeError
Return value of DigitalCreative\CollapsibleResourceManager\Resources\TopLevelResource::parseResource() must be an instance of DigitalCreative\CollapsibleResourceManager\Resources\AbstractResource or null, instance of Eboye\LaravelNovaTranslationEditor\LaravelNovaTranslationEditor returned (View: D:\Eurocoders\hosting\nova\resources\views\layout.blade.php)"
My code is this:
public function tools()
{
$resources = [];

  .....
    $resources[] = Group::make([
        'label' => 'System',
        'resources' => [
            \App\Nova\Plan::class,
            \App\Nova\PaymentMethod::class,
            \App\Nova\Coupon::class
        ]
    ]);

    $resources[] = Group::make([
        'label' => 'Articles',
        'resources' => [
            \App\Nova\Article::class,
            \App\Nova\ArticleCategory::class
        ]
    ]);

    $resources[] = Group::make([
        'label' => 'Pages',
        'resources' => [
            \App\Nova\Page::class,
            \App\Nova\Faq::class,
            \App\Nova\Review::class
        ]
        
    ]);
    $resources[] = Group::make([
        'label' => 'Translations',
        'resources' => [
             new LaravelNovaTranslationEditor
            ]
                
        ]);
    # Define variable to hold the available custom tools
    $customTools = [];

    $customTools[] = new \BinaryBuilds\NovaAdvancedCommandRunner\CommandRunner;

    # Define variable to hold the navigation
    $navigation = [ new CollapsibleResourceManager([
        'navigation' => [
            TopLevelResource::make([
                'label' => 'Resources',
                'resources' => $resources
            ])                    
        ]
    ]) ];

        # Merge the custom tools with resources navigation
        return array_merge($navigation, $customTools);
}
@eboye
Copy link
Owner

eboye commented Nov 8, 2023

Hmm, I think it's because of new Nova menu structure. In new version it's completely different.

I haven't used this library with new Nova version. I will check how it should be done, but for now, just try to add it like this:

/**
     * Get the tools that should be listed in the Nova sidebar.
     *
     * @return array
     */
    public function tools(): array
    {
        return [
                new LaravelNovaTranslationEditor()
        ];
    }
    
        /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(): void
    {
        parent::boot();

        Nova::mainMenu(function (Request $request) {
            return [
                    MenuSection::make('Translation')->path('/laravel-nova-translation-editor/index')
            ];
        }
    }

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