Answer the question
In order to leave comments, you need to log in
How to fix route conflict?
I want to get users by their current department:
Route::apiResource('staffs/{staff_id}/users', UserController::class);
Route::apiResource('users/{user_id}/staffs', ?::class);
Route::apiResource('staffs', StaffController::class);
Answer the question
In order to leave comments, you need to log in
apiResource
it makes sense only for and then only if you have index, store, show, update, destroy ( https://laravel.com/docs/8.x/controllers#actions-h... )
Route::apiResource('staffs', StaffController::class);
__invoke
the class will be suitableRoute::get('staffs/{staff_id}/users', UserStaffController::class);
Route::get('users/{user_id}/staffs', StaffUserController::class);
/users?staff_id=1
and a list of departments that have a user. /staffs?user_id=1
Route::apiResource('users', UserController::class);
Route::apiResource('staffs', StaffController::class);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question