Answer the question
In order to leave comments, you need to log in
Is it possible to exclude a parameter in the router?
How to apply to the first one so that it does not take into account the parameter in the id word remove
Is there something like this? ->name('upload.index')->where('id', ''!=, 'remove')
Tried the regex from the docks, but it doesn't help. There's an example like this - ->where('id', '[0-9]+');
I tried like this: ->where('id', '![remove]'); and so: ->where('id', '[!remove]');
Maybe I'm not doing the regular expression right?
Route::get('/upload/{id}', '[email protected]_index')->name('upload.index');
Route::get('/upload/remove', '[email protected]_remove')->name('upload.remove');
Answer the question
In order to leave comments, you need to log in
such an option
Route::get('/upload/{id}', '[email protected]_index')->where('id', '^(!remove$)')->name('upload.index');
Route::get('/upload/remove', '[email protected]_remove')->name('upload.remove');
It is wrong to restrict a route by what it should not accept.
Correctly - to define what parameters it SHOULD accept. Because the number of values that should not take - can increase, and route should not respond to them.
So:
Route::get('/upload/{id}', function(){
return 'id integer';
})->where('id','[\d]+')
->name('upload.index');
Route::get('/upload/remove', function(){
return 'remove';
})->name('upload.remove');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question