دنبال کننده ها

۱۳۹۶ دی ۱۱, دوشنبه

php - How to Create a pattern for URL parameters in Laravel

[ad_1]



I wrote this code in file RouteServiceProvider.php that is located in app/Providers directory. in method boot:




$this->pattern('id', '[0-9]+');



then according to what I read, I thought if I write this code:




Route::get('/user/id', function ($id)
return $id;
);



in file web.php in routes directory the id parameter accept just int value, but when i test this url: http://127.0.0.1:8000/user/a I saw a is returned.
Now the question is:



  1. where is the problem?

2.how can I make pattern?




[ad_2]

لینک منبع