“Laravel Route Optionaler Parameter” Code-Antworten

Laravel Routen -Namespace und Präfix

Route::prefix('admin')->group(function () {
    Route::get('/users', function () {
        // Matches The "/admin/users" URL
    });
});
Perfect Plover

Laravel -Route

Route::get('user/{id}', function ($id) {
    return 'User '.$id;
});
Enthusiastic Elephant

Laravel Route Optionaler Parameter

// You can make a parameter optional by placing a '?' after the parameter name.
// Make sure to give the route's corresponding variable a default value:
Route::get('user/{name?}', function ($name = null) {
    return $name;
});

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

Laravel -Route

Route::get('user/profile', [UserProfileController::class, 'show'])->name('profile');
Sleepy Sandpiper

Setzen Sie den Routennamen Laravel

Route::get('/novanoticia', 'HomeController@getNovaNoticia')->name('route_name');
Route::get('/novanoticia', ['as' => 'route_name', 'uses' => 'HomeController@getNovaNoticia']);
Toukir_Ahmed

Laravel (8) - Routing zum Controller mit optionalen Parametern

---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...
        
     }

  
Xfantasia

Ähnliche Antworten wie “Laravel Route Optionaler Parameter”

Fragen ähnlich wie “Laravel Route Optionaler Parameter”

Weitere verwandte Antworten zu “Laravel Route Optionaler Parameter” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen