Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Laravel (8) - Routing to controller with optional parameters

---web.php---
Route::get('/api/webhook/{val1?}/{val2?}/{val3?}', [AppHttpControllersXyzController::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...
        
     }

  
 
PREVIOUS NEXT
Tagged: #Laravel #Routing #controller #optional #parameters
ADD COMMENT
Topic
Name
8+1 =