V
V
Vitaly2019-01-07 15:41:19
Laravel
Vitaly, 2019-01-07 15:41:19

How to assign a default value to an optional variable in Laravel routing?

The documentation says to do this

Route::get('user/{name?}', function($name = null)
{
    return $name;
});

but how to assign a default value here?
Route::get('date/{date?}', '[email protected]')->name('ajax.matches.date')->middleware('enter');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vism, 2019-01-07
@kiukishenkaec

Logically - in the controller.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question