I have a route of feedback which is accessible to both users
and chancellors
prefixes, but the issue is that I want to write it once in web.php
, now I have to write it multiple times in users
and chancellors
prefixes also I have to change the route name which I don’t want to do. Is there any way to do this?
When I use it normally out of the users
and chancellors
prefixes it is accessible to both, but it lacks the users
and chancellors
prefixes. I want to write this route once and when the user logins with the users
or chancellors
prefixes such that the users/report-feedback
or chancellors/report-feedback
Route::get('/report-feedback', [FeedbackController::class, 'feedbackForm'])->name('feedbackForm.get');
2
Answers
If you want multiple routes you’ll need to define them multiple times. You can use route groups to put routes together, but pre-define the callback function used as the argument:
So this will create a route for the URL
users/report-feedback
namedusers.feedbackForm.get
, and another for the URLchancellors/report-feedback
namedchancellors.feedbackForm.get
.You can use