Laravel 8 + PHP 8: using optional route optional parameter give "Cannot use positional argument after named argument"

Viewed 452

Using Laravel 8 with PHP 8, and trying to set up optional parameters in routing:

Route::prefix('manual')->group(function () {
    Route::get('/{type}/{topic?}/{subtopic?}', 'PageController@manual')
        ->name('manual');
})

controller (tried both false and null):

public function manual($type, $topic = false, $subtopic = false) {

gives the following error:

Symfony\Component\Debug\Exception\FatalThrowableError
Cannot use positional argument after named argument

when I call this route URL like /manual/manualName or /manual/manualName/a/b How can I solve it?

0 Answers
Related