Voyager: UnexpectedValueException Invalid route action: [AnyController].

Created on 11 Oct 2018  路  8Comments  路  Source: the-control-group/voyager

Version information

  • Laravel: v5.7.9
  • Voyager: v1.1.7
  • PHP: 7.1.7
  • Database: Ver 14.14 Distrib 5.7.19, for Win64 (x86_64)

Description


at the time of adding a new Bread menu item (after create Bread),
error occurs when have is a invoke controller (Single Action Controllers)

Steps To Reproduce

Steps to reproduce the behavior:

  1. Go to console
  2. Create a invoke controller
    example php artisan make:controller IndexController --invokable
  3. Register you controller in router
    example Route::get('/', 'IndexController');
  4. Go to /admin/bread and create new bread for any table (maybe you need create a table),
    fill data and press submit
  5. Look error.

Expected behavior

Standart behavior bread creating

Screenshots

https://screenshots.firefox.com/M6IoFQwFGXF6wYMb/flame.raiders

Additional context

While looking for what's the problem

Most helpful comment

I discovered the cause of the problem

https://github.com/the-control-group/voyager/blob/4b6b3a3f7cf30abc1220c503a12858d41c653486/src/Listeners/AddBreadMenuItem.php#L32
This is incorrect mrthod for require routes!

Just check RouteServiceProvider in Laravel:
https://github.com/laravel/laravel/blob/2a483bbf60566cab6fbd0340fb3877fc09889bc3/app/Providers/RouteServiceProvider.php#L54-L56

Route::middleware('web') - set group for routes
->namespace('App\Http\Controllers') - set namespaces for controllers!!!
->group(base_path('routes/web.php')); - require routes!

All 8 comments

This doesn't really seem like a Voyager problem. Can you provide the code for your IndexController? It sounds like it's missing the __invoke method

controller have base code after php artisan make:controller IndexController --invokable
this is test base on clear laravel + voyager

@Xmk more details required.

I have the same problem. If I use invoke controller, voyager will crash when I create a bread.

code:

route/web.php

<?php
Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');


Route::group(['prefix' => 'admin'], function () {
    Voyager::routes();
});

Route::get('/welcome', 'Welcome');
app\Http\Controllers\Welcome.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class Welcome extends Controller
{
    /**
     * Handle the incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function __invoke(Request $request)
    {
        return view('welcome');
    }
}

2018-11-19 11-01-51
2018-11-19 11-00-51

I discovered the cause of the problem

https://github.com/the-control-group/voyager/blob/4b6b3a3f7cf30abc1220c503a12858d41c653486/src/Listeners/AddBreadMenuItem.php#L32
This is incorrect mrthod for require routes!

Just check RouteServiceProvider in Laravel:
https://github.com/laravel/laravel/blob/2a483bbf60566cab6fbd0340fb3877fc09889bc3/app/Providers/RouteServiceProvider.php#L54-L56

Route::middleware('web') - set group for routes
->namespace('App\Http\Controllers') - set namespaces for controllers!!!
->group(base_path('routes/web.php')); - require routes!

@Xmk please close this ticket. Thanks for the updated response champ.

@Sylk The issue is still active so I don't think this should be closed. I'm experiencing the same thing and it's really annoying.

@Xmk Pointed out the issue - but it doesn't seem like it was fixed or addressed yet. Honestly from my local testing it seems like line 32 should just be removed.

https://github.com/the-control-group/voyager/blob/4b6b3a3f7cf30abc1220c503a12858d41c653486/src/Listeners/AddBreadMenuItem.php#L32

It doesn't seem to do anything other than cause this error to be thrown. After removing that line, the Bread creation worked as expected and a Menu item was added.

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vaggelis2018 picture vaggelis2018  路  3Comments

iwasherefirst2 picture iwasherefirst2  路  3Comments

zzpwestlife picture zzpwestlife  路  3Comments

wislem picture wislem  路  3Comments

craigb88 picture craigb88  路  3Comments