Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh

Route Parameters Validation with RegExp in Laravel

We can validate parameters directly in the route, with “where” parameter. A pretty typical case is to prefix your routes by language locale, like fr/blog and en/article/333. How do we ensure that those two first letters are not used for some other than language?


   'prefix' => '{locale}',
    'where' => ['locale' => '[a-zA-Z]{2}']
      ], function () {
             Route::get('/', 'HomeController@index');
            Route::get('article/{id}', 'ArticleController@show');


Add new comment

Restricted HTML


Page Facebook

Become a patron

If you need some help or you search a Drupal freelancer don't hesitate to contact us.


Contact Us

All the content is FREE but I still need your help


Become a patreon