B L Praveen
B L Praveen

Reputation: 1990

trim() expects parameter 1 to be string, array given in laravel

If I add this to api.php route I get this error

 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']);

Error occurs in the line

protected function prefix($uri)
{
    return trim(trim($this->getLastGroupPrefix(), '/').'/'.trim($uri, '/'), '/') ?: '/';
}

Upvotes: 1

Views: 3595

Answers (1)

Md.Sukel Ali
Md.Sukel Ali

Reputation: 3065

Just remove [] from your route.

 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');

Upvotes: 2

Related Questions