user3552264 user3552264 - 1 month ago 13
PHP Question

ReflectionException in Route.php line 335: Function () does not exist

I'm tryin to get this grid (http://www.mariogallegos.com/tutorials/crud-custom-form) to work in Laravel 5.3.19.

I'm getting the exception:
ReflectionException in Route.php line 335: Function () does not exist

In my web.php i have the followingcode:

Route::group(['middleware' => 'sidebarmenu'], function()
{
Route::get('/home', [
'as' => 'home',
'uses' => 'HomeController@index'
]);

Route::get('/users', [
'as' => 'users',
GridEncoder::encodeRequestedData(new UserRepository(new User()), Request::all())
]);

});

Answer

You need to wrap your controller code with a function callback.

Replace

Route::get('/users', [
 'as' => 'users', 
 GridEncoder::encodeRequestedData(new UserRepository(new User()), Request::all());
]);

with

Route::get('/users', function() { 
  GridEncoder::encodeRequestedData(new UserRepository(new User()), Request::all());
})->name('users');
Comments