I found some great resources that give me some powerful advice when writing a route and I wanted to share them with you for your future projects. Use more than one resources and Controller in one resources

Route::get('photos/popular', 'PhotoController@method'); Route::resource('photos', 'PhotoController'); Group in Another Group // public routes Route::get('/', 'HomeController@index'); // Logged-in users - with "auth" middleware Route::group(['middleware' => ['auth']], function () { // /user/XXX: In addition to "auth", this group will have middleware "simple_users" Route::group(['middleware' => ['simple_users'], 'prefix' => 'user'], function () { Route::resource('tasks', 'TaskController'); }); // /admin/XXX: This group won't have "simple_users", but will have "auth" and "admins" Route::group(['middleware' => ['admins'], 'prefix' => 'admin'], function () { Route::resource('users', 'UserController'); }); }); Route Parameter Validation – Multi-Language The main part here is ‘where’ => [‘locale’ => ‘[a-zA-Z]{2}’] where we use a regular expression to match only two-letter combinations

So, if you want to create V2 route group, you can create a separate routes/api_v2.php and do this public function map() { //... older functions $this->mapApiV2Routes(); }

Route::middleware('auth:api', 'throttle:rate_limit,1')->group(function () { Route::get('/user', function () { // }); }); Route List and Route Caching you can check your actual route with Artisan command php artisan route:list after every change of your routes, you need to launch command php artisan route:clear
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