This is my routes.But I'm getting "Missing required parameter for route, missing parameter {user}". I didn't get this error before adding multilanguage. How can I fix that error. None of my show functions are working.
My Controller:
public function show($locale,User $user)
{
return view('admin.users.show', compact('user'));
}
View file (admin.users.show):
Working fine, but If I add it returns error.
"Missing required parameter for [Route: admin.users.show] [URI: {locale}/admin/users/{user}] [Missing parameter: user].
I face same problem for every show functions. Can you help to solve this problem?
Well, you answered your question yourself, the error is in the dropdown link where you put only the locale as a parameter and nothing else. The route is empty as I see, or maybe it was badly formatted, but if you want to redirect to the same route with locale you need to pass user, too.
This is my routes.But I'm getting "Missing required parameter for route, missing parameter {user}". I didn't get this error before adding multilanguage. How can I fix that error. None of my show functions are working.
What is the URL you're calling? If should be something like
/en/users/1
to get a user, because you have the required "locale" now.I'm calling like this: href="{{ route('admin.users.show', ['user' => $u ]) }}"
First step: Show link in users table: href="{{ route('admin.users.show', ['user' => $u ]) }}"
Routes: Route::get('/', function () { return redirect(app()->getLocale()); })->name('main'); Route::prefix('{locale}')->where(['locale' => '[a-zA-Z]{2}'])->middleware('setlocale')->group(function () { Route::middleware('role:1')->prefix('admin')->name('admin.')->group(function () { Route::resource('users', Admin\UsersController::class ); }); });
My Controller: public function show($locale,User $user) { return view('admin.users.show', compact('user')); }
View file (admin.users.show): Working fine, but If I add it returns error. "Missing required parameter for [Route: admin.users.show] [URI: {locale}/admin/users/{user}] [Missing parameter: user].
I face same problem for every show functions. Can you help to solve this problem?
When I remove this code: x-dropdown-link :href="route(, ['locale' => $locale])" :active="app()->getLocale() == $locale" /x-dropdown-link
It's working fine. In show pages.
Well, you answered your question yourself, the error is in the dropdown link where you put only the locale as a parameter and nothing else. The route is empty as I see, or maybe it was badly formatted, but if you want to redirect to the same route with locale you need to pass user, too.