Just make it impossible to call /article/something:
Route::get('/article/{id}', 'ArticleController@getArticle')->where('id', '[0-9]+');
Sharping said:
Just make it impossible to call /article/something:
Route::get('/article/{id}', 'ArticleController@getArticle')->where('id', '[0-9]+');
No. I handle this on before => "number"
That is not how you use filters, use Route::pattern()
or Route::get()->where()
as user Sharping suggested.
delmadord said:
That is not how you use filters, use
Route::pattern()
orRoute::get()->where()
as user Sharping suggested.
If I use ->where('id', '[0-9]+'); when use trying to access like api/article/dasdad -> it throw an error 404 not found exception. But my question is I want to throw to my error exception.
I use this {id?} and on my method ($id = 0)
it working for now.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community