PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Solved

Route [voyager.theme.index] not defined.

Solved
derekbuntin

Jan 26th, 2019 08:25 AM

I installed a fresh version of wave, which was all working fine.

Updated:

  • Laravel > 5.7*
  • tymon/jwt-auth > 1.0.0-rc.3

When visiting voyager admin I get the following error:

laravel.ERROR: Route [voyager.theme.index] not defined. (View: /users/derekbuntin/websites/wave/vendor/tcg/voyager/resources/views/dashboard/sidebar.blade.php)

If I edit vendor/voyager-themes/src/VoyagerThemesServiceProvider.php and comment out line 35:

$this->addThemeMenuItem($menu);

Admin displays correctly without the routes to the themes section.

The same thing happens when you activate Voyager Redirects

Route [voyager.redirects] not defined.

UPDATE

This issue arose after updaing Voyager 1.1 to 1.1.10, I can confirm the hooks worked perfectly before the update but do not work with the latest version of Voyager. I have submitted a Github issue for this and await a reply.

derekbuntin

Feb 5th, 2019 07:03 AM

Best Answer

I solved this issue myself so here is what's needed:

VoyagerThemesServiceProvider.php

Change the 'register' method from this:

public function register()
    {
        if (request()->is(config('voyager.prefix')) || request()->is(config('voyager.prefix').'/*')) {
            $this->addThemesTable();

            app(Dispatcher::class)->listen('voyager.menu.display', function ($menu) {
                $this->addThemeMenuItem($menu);
            });

            app(Dispatcher::class)->listen('voyager.admin.routing', function ($router) {
                $this->addThemeRoutes($router);
            });
        }

        // publish config
        $this->publishes([dirname(__DIR__).'/config/themes.php' => config_path('themes.php')], 'voyager-themes-config');

        // load helpers
        @include __DIR__.'/helpers.php';
    }

To this:

public function register()
    {
        //if (request()->is(config('voyager.prefix')) || request()->is(config('voyager.prefix').'/*')) {
            $this->addThemesTable();

            app(Dispatcher::class)->listen('voyager.menu.display', function ($menu) {
                $this->addThemeMenuItem($menu);
            });
						
            app(Dispatcher::class)->listen('voyager.admin.routing', function ($router) {
                $this->addThemeRoutes($router);
            });
       // }

        // publish config
        $this->publishes([dirname(__DIR__).'/config/themes.php' => config_path('themes.php')], 'voyager-themes-config');

        // load helpers
        @include __DIR__.'/helpers.php';
    }

Within the addThemesRouter method change line 104 to:

$router->get('themes/options', $namespacePrefix.'ThemesController@index');
        /*$router->get('themes/options', function () {
            return redirect(route('voyager.theme.index'));
        });*/

Everything now works as expected, it would be interesting to know when the voyager-themes hook will be updated?