vendredi 13 juillet 2018

Laravel access route parameter in route web.php file

If I have something like this:

Route::group(['prefix' => '/'], function()
{
    if ( condition )
    {
        Route::get('/route/{id}', 'ControllerA@methodA')->name('some_name');
    } else{
        Route::get('/route{id}', 'ControllerB@methodB')->name('some_name');;
    }
});

How can I use the {id} parameter in the if (condition)? I tried

Route::group(['prefix' => '/'], function($id)
    {
        if ( $id == 1)

And it's not working.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire