Support the ongoing development of Laravel.io →
Security Requests
Last updated 2 years ago.
0

Just make it impossible to call /article/something:

Route::get('/article/{id}', 'ArticleController@getArticle')->where('id', '[0-9]+');
Last updated 2 years ago.
0

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"

Last updated 2 years ago.
0

That is not how you use filters, use Route::pattern() or Route::get()->where() as user Sharping suggested.

Last updated 2 years ago.
0

delmadord said:

That is not how you use filters, use Route::pattern() or Route::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.

Last updated 2 years ago.
0

I use this {id?} and on my method ($id = 0)

it working for now.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

iClosedz iclosedz Joined 10 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.