Error when trying to view page, following error: Action Facade\Ignition\Http\Controllers\ShareReportController not defined

两盒软妹~` 提交于 2019-12-13 03:21:18

问题


I am getting the error below when trying to access the route, but the controller is needed to load the data:

(1/1) InvalidArgumentException
Action Facade\Ignition\Http\Controllers\ShareReportController not defined.

I am using Tenancy/Multi-Tenant package and I have configured it to use routes/tenants.php to load routes specifically for tenants. If I do the following in the tenants.php file, it returns the proper response.

Route::get('/test', function() {
    return 'Test success';
});

though when I try to do the same, but loading the data from a controller such as this:

Route::get('/testt', 'TenantController@testt');

It will show the error:

(1/1) InvalidArgumentException
Action Facade\Ignition\Http\Controllers\ShareReportController not defined.

If i try to put the same code in web.php routes, then it works perfectly. What could be the problem? Is it something in my code? Can it be because of the multi-tenant package i'm using? How would i go about further debugging this?


回答1:


The fix was to group the routes in tenants.php with the web middleware and a namespace:

Route::middleware('web')->namespace('App\Http\Controllers')->group(function() {
    //Routes
});



回答2:


Try composer dump-autoload -o it helped for me.




回答3:


After some minutes trying to fix I found the solution.

You don't need to group the routes if you've done in RoutesServiceProvider or in a custom Provider.

Just go to config/tenancy.php and go to routes -> path, Remove the base_path() function and let the string:

'path'           => base_path('routes/tenants/tenants.php'),

to

'path'           => 'routes/tenants/tenants.php',

And this error should be fixed.




回答4:


Can you see if your routes are cached and try clearing that cache. Just clear project route-cache using route:clear



来源:https://stackoverflow.com/questions/58172361/error-when-trying-to-view-page-following-error-action-facade-ignition-http-con

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!