1
votes

when i try to access routes as guests with Auth middle ware it says that Missing required parameters for [Route: login] [URI: {lang}/login]. this is because i added localization to my website. here is my home controller

class HomeController extends Controller { /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('auth'); $this->middleware('verified'); }

/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Contracts\Support\Renderable
 */
public function index($lang)
{
   \App::setlocale($lang);

   return view('home');
    }

this is my authenticate.php middleware

protected function redirectTo($request)
{
    if (! $request->expectsJson()) {
        return route('login' , app()->getLocale());
    }
}
2

2 Answers

0
votes

Try after changing App::setlocale($lang) to App::setLocale($lang) in your index method. getLocale as of now is probably empty (but setlocale should have thrown an error if I'm not mistaken)

protected function redirectTo($request)
{
if (! $request->expectsJson()) {
     return route('login' , app()->getLocale()); //getLocale probably return empty value
 }
}
0
votes
return route('login', ['lang' => app()->getLocale()])

You should pass the parameter of lang like this, inside an array of parameters.