Multiple Language Route w/ Model Collection

Posted 8 months ago by splendidkeen

While implementing multiple languages, I face some issues with my Routes. Logically, Users can adjust languages within the footer, which will trigger the following Route

Route::get('/lang/{lang?}', function($lang=NULL){
    return view('home');

But if I need to add a collection of Partners or something similar on the homepage, I normally structure my routes this way:

Route::get('/', '[email protected]')->name('home');

// HomeController

public function index()
        $partners = Partner::orderBy('created_at', 'desc')->get(); 

        return view ('home', compact('partners'));

How can I add the partners Collection to the language route structure?

Could there be problems with a home redirect, because basically the home.blade.php Route is / and not /lang/{lang?}.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.