0
votes

I am using Laravel 7.x, I have a controller which when called in the routes, instead of loading its own called method, will rather load the method of a different controller, I don't know how and why?

I.e. Controller-A executes Controller-B methods which was not called.

So, I am calling the route below from my web.php directory.

Route::get('/testx', 'ControllerA@show_table');

but it loads another ControllerB's method instead thereby loading the wrong route. Does laravel cache controllers? Its a strange logic error to me.

1
try php artisan route:clear (laravel may be caching routes, not controllers)Alberto Sinigaglia
Are you sure there is only one /testx route in your web.php?zlatan
You probably have a wildcard route for /{something} in your routes file. Make sure that route is below everything else, especially the /testx routeaynber
Thanks @zlatan, thats the only route in the web.php file.ATSU EMMANUEL
Thanks @Berto99, i have tried the command but still the same.ATSU EMMANUEL

1 Answers

0
votes

Thank you guys for your response. I finally solved the problem. I had earlier saved a controller with the same class as the current controller while running a test, and forgot to remove it from the controller directory, this was the cause of error "Duplicate Class" in the same namespace. I simply removed the duplicate class controller and the issue was resolved.