Answers for "routing to controller with optional parameters laravel 8"

PHP
0

Laravel (8) - Routing to controller with optional parameters

---web.php---
Route::get('/api/webhook/{val1?}/{val2?}/{val3?}', [App\Http\Controllers\XyzController::class, 'xprocess'])->name('xprocess');

---XyzController.php---
    public function xprocess(Request $request, $val1=null, $val2=null, $val3=null)
    {
        $val1 = $request->query('val1');
        $val2 = $request->query('val2');
        $val3 = $request->query('val3');
        
        //process variables etc...
        
     }
Posted by: Guest on October-29-2021
0

laravel route optional parameters

Route::get('user/{name?}', function ($name = null) {
    return $name;
});

Route::get('user/{name?}', function ($name = 'John') {
    return $name;
});
Posted by: Guest on July-24-2021

Code answers related to "routing to controller with optional parameters laravel 8"

Browse Popular Code Answers by Language