Multiple Language Route w/ Model Collection

Posted 4 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.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.