Laravel 5.1 路由不需要数组
Laravel 5.1 route not expecting array
我有以下路线:
use NexCast\Domain\NiveisServico\NiveisServicoController;
Route::group(['prefix' => 'niveis-servico', 'name' => 'niveis-servico.'], function () {
Route::get('/', [NiveisServicoController::class, 'getData'])->name('get');
Route::post('/', [NiveisServicoController::class, 'saveData'])->name('save');
Route::delete('/', [NiveisServicoController::class, 'deleteData'])->name('delete');
});
但是我收到以下错误:
Type error: ReflectionFunction::__construct() expects parameter 1 to be string, array given
我做错了什么?
您遇到的错误是因为您将数组作为第二个参数传递给组内的 Route:: 方法,但它需要一个字符串。这是使用您的代码时它们应该是什么样子的示例:
Route::get('/', 'NiveisServicoController@getData')->name('get');
您可以在 docs for the Laravel 5.1 version 中找到有关路线的更多信息。
我有以下路线:
use NexCast\Domain\NiveisServico\NiveisServicoController;
Route::group(['prefix' => 'niveis-servico', 'name' => 'niveis-servico.'], function () {
Route::get('/', [NiveisServicoController::class, 'getData'])->name('get');
Route::post('/', [NiveisServicoController::class, 'saveData'])->name('save');
Route::delete('/', [NiveisServicoController::class, 'deleteData'])->name('delete');
});
但是我收到以下错误:
Type error: ReflectionFunction::__construct() expects parameter 1 to be string, array given
我做错了什么?
您遇到的错误是因为您将数组作为第二个参数传递给组内的 Route:: 方法,但它需要一个字符串。这是使用您的代码时它们应该是什么样子的示例:
Route::get('/', 'NiveisServicoController@getData')->name('get');
您可以在 docs for the Laravel 5.1 version 中找到有关路线的更多信息。