I just upgraded from Laravel 5.2 to 5.3. I am using Laravel-DataTables package for several tables in my application.
After upgrade when I run
artisan serve I’m receiving:
[BadMethodCallException] Method controller does not exist.
I’ve tracked the issue down to this piece of code in my
Route::controller('datatables', 'ProfileController', [ 'anyOrders' => 'datatables.dataOrders', 'anyProperties' => 'datatables.dataProperties', ]);
This is the suggested way to route the queries for DataTables Documentation.
Route::controller() deprecated, and what is the alternative to for these routes?
routes will be:
Route::get('/datatables/orders', array('middleware' => 'auth', 'uses' => '[email protected]'))->name('datatables.dataOrders'); Route::get('/datatables/properties', array('middleware' => 'auth', 'uses' => '[email protected]'))->name('datatables.dataProperties');
I had the same issue as you, and none of the alternatives (explicit declaration or publishing) was good enough. There were also some alternatives which required changing too much code.
This is why I wrote a class called AdvancedRoute, which serves as a drop in replacement.
It can be used by simply replacing Route::controller with AdvancedRoute::controller like this:
Full information how to install and use find at the GitHub repo at:
Hope you find this useful.
The following features are deprecated in 5.2 and will be removed in the 5.3 release in June 2016:
- Implicit controller routes using
Route::controllerhave been deprecated. Please use explicit route registration in your routes file. This will likely be extracted into a package.
You can use resource().
Note: the “get” prefix is not needed.