Getting error : Another route has already been assigned name
akhilkharva opened this issue · 2 comments
akhilkharva commented
I have created two routes with respective api and web:
// Task 12: Manage tasks with endpoint /api/v1/tasks/*****.
// Keep in mind that prefix should be /api/v1.
// Add ONE line to assign 5 resource routes to TaskController
// Put one code line here below
Route::apiResource('tasks', TaskController::class);
// Task 8: Manage tasks with URL /app/tasks/***.
// Add ONE line to assign 7 resource routes to TaskController
// Put one code line here below
Route::resource('tasks', TaskController::class);
both are calling different controller, but it gives me error that ( i have already added prefix api/v1 for api route )
Unable to prepare route [app/tasks] for serialization. Another route has already been assigned name [tasks.index].
How to handle this?
PovilasKorop commented
@akhilkharva just a guess, but maybe you created API route inside of the routes/web.php and not routes/api.php?
akhilkharva commented
Hey @PovilasKorop , well its a API route, anyways some how i resolved that issue but its quite surprising that
Route::group(['prefix' => 'v1', 'namespace' => 'api/v1', 'middleware' => 'auth:sanctum'], function () {
// Task 12: Manage tasks with endpoint /api/v1/tasks/*****.
// Keep in mind that prefix should be /api/v1.
// Add ONE line to assign 5 resource routes to TaskController
// Put one code line here below
Route::apiResource('tasks', TaskController::class);
});
gives error... While if i put prefix in route-url, it resolved.