“parameter opsional rute rute” Kode Jawaban

Laravel Route Namespace dan awalan

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

Rute Laravel

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

parameter opsional rute rute

// 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

Rute Laravel

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

Tetapkan nama rute Laravel

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

Laravel (8) - Routing ke controller dengan parameter opsional

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

Jawaban yang mirip dengan “parameter opsional rute rute”

Pertanyaan yang mirip dengan “parameter opsional rute rute”

Lebih banyak jawaban terkait untuk “parameter opsional rute rute” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya