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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners