Category: Laravel

With routing you can specify Route::get(‘projects/{project_id}’, ‘ProjectController@show’); but what if you want project_id to be strictly a number?
To achieve that, you can put where() condition on any Route statement, and use regular expressions for specifying data pattern.
Not only that, you can specify that some variable name would always follow a certain pattern.
Like, for example, you want project_id in all routes to be integer.
Then you do this in app/Providers/RouteServiceProvider.php:public function boot() { Route::pattern('project_id', '[0-9]+'); parent::boot(); }
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners