如果将其添加到api.php路由中,则会出现此错误
trim() expects parameter 1 to be string, array given in laravel
Route::get(['chapter/{chapter_id}/quiz' , 'API\QuizController@index']);
Route::post(['chapter/{chapter_id}/quiz' , 'API\QuizController@store']);
Route::put(['chapter/{chapter_id}/quiz/{id}' , 'API\QuizController@update']);
该行中发生错误
protected function prefix($uri)
{
return trim(trim($this->getLastGroupPrefix(), '/').'/'.trim($uri, '/'), '/') ?: '/';
}
答案 0 :(得分:1)
只需从您的路线中删除[]
。
Route::get('chapter/{chapter_id}/quiz' , 'API\QuizController@index');
Route::post('chapter/{chapter_id}/quiz' , 'API\QuizController@store');
Route::put('chapter/{chapter_id}/quiz/{id}' , 'API\QuizController@update');