2 years ago

Routes overlap

Posted 2 years ago by roemer


I have the following route group:

        'prefix' => 'thing',
    ], function() {
        Route::get('all', 'API\[email protected]')->middleware('checkIfUserIsInThing');
        Route::post('create', 'API\[email protected]')->middleware('checkIfUserIsInThing');
        Route::post('update', 'API\[email protected]')->middleware('checkIfUserIsInThing');
        Route::delete('destroy/{id}', 'API\[email protected]')->middleware('checkIfUserIsInThing');
        Route::get('{id}', 'API\[email protected]')->middleware('checkIfUserIsInThing');
        Route::get('{id}/users', 'API\[email protected]')->middleware('checkIfUserIsInThing');

I think it's pretty clear what these routes do. This causes an issue though. When I try to use the all route, it thinks 'all' is the {id} for the Route::get('{id}'). I assumed this would not happen if I define the all route first, but apparently it does. How do I resolve this?

Please sign in or create an account to participate in this conversation.