laravel web and api routes code example
Example 1: laravel route match
Route::match(['get', 'post'], '/', function () {
//
});
Route::any('/', function () {
//
});
Example 2: laravel route optional parameter
Route::get('/sample/{param?}', 'SampleController@index');
Example 3: laravel api routes
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);