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 the behavior:
php artisan make:controller IndexController --invokableRoute::get('/', 'IndexController');Standart behavior bread creating
https://screenshots.firefox.com/M6IoFQwFGXF6wYMb/flame.raiders
While looking for what's the problem
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');
}
}


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.
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.
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!