'In Laravel, how to route GET and POST requests for the same pattern? [duplicate]

Is there a method to consolidate these two lines into a single line in Laravel 8?

Route::get('register', 'AuthController@getLogin');
Route::post('register', 'AuthController@postLogin');


Solution 1:[1]

Route::match(['get', 'post'], '/register', AuthController@getAndPostLogin);

Source: https://laravel.com/docs/9.x/routing#available-router-methods

Solution 2:[2]

For a route, you can use the following syntax to aggregate all HTTP verbs:

Route::any('register', 'AuthController@login');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Musa
Solution 2 Abantimayee Rath