添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

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:

  • Go to console
  • Create a invoke controller
    example php artisan make:controller IndexController --invokable
  • Register you controller in router
    example Route::get('/', 'IndexController');
  • Go to /admin/bread and create new bread for any table (maybe you need create a table),
    fill data and press submit
  • 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

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

    code:

    route/web.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
    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!

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

    * Fix issue #3623
    The line I'm removing is the cause of #3623. Once removed the BREAD creation seems to work as expected, however with it included it just causes exceptions to be thrown.
    * Remove whitespace to make StyleCI happy