I have this route in my routes/web.php
:
Route::get('/checkout', [CheckoutController::class, 'index'])->name('checkoutIndex')->middleware('auth');
My CheckoutController
:
function index()
{
if (Cart::instance('default')->count() == 0) {
return redirect()->route('cartIndex', App::getLocale())->withErrors('Your shopping cart is empty! Please select an item to checkout.');
}
$discount = session()->has('coupon') ? session()->get('coupon')['discount'] : 0;
return view('checkout_index')->with(['lang' => App::getLocale(), 'discount' => $discount]);
}
When I’m not logged in and go to the URL it takes me to a login page as it should. but the login page gives a Missing required parameter for [Route: login] [URI: {lang}/login] [Missing parameter: lang].
error.
The login page works well in its own route anywhere else in the app, I only get the error by clicking on this one specific link:
<a class="btn btn-primary text-light p-3 rounded-0" href="{{ route('checkoutIndex', App::getLocale()) }}">{{__('Proceed to Checkout')}}</a>
I believe having middleware is causing the issue.
I’m using the laravel built-in auth. the route to login is Auth::routes();
Any ideas?
2
Answers
could you try this
in your AppHttpMiddlewareAuthenticate middleware
You need to pass the required parameter to the route:
change this line:
to