Laravel/PHP Articles

Articles from Laravel/PHP sites on the web

Laravel/PHP Articles
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(); }

Sign Up For Our Newsletter

Each Week, We curate the top Laravel/PHP articles, jobs, events and More!

We'll send you a weekly email with the latest Laravel/PHP articles, jobs and events. Please review our Code of Conduct in the meantime. Talk to you soon!