Pass variables by routes

Asked

Viewed 72 times

0

Hello, I’m creating a website in Laravel for the first time, and is a website in 3 different languages. In partials, he owns the header, that has the option of the 3 languages, when I click on one, I want to pass a variable telling which language is active for the rest of the site. But I couldn’t quite figure out how to do it.

Here is where the variable has to be sent.

<a href="{{ route('website.index') -> with('lang', $request->lang)}}">
    <img src="https://img.icons8.com/color/48/000000/brazil.png" />
</a>

How to make her welcome on index and too views?

Route::match(['get', 'post'], '/', 'WebsiteController@index')->name('website.index');

Route::get('header/{lang}', function(Request $resquest){
        return Redirect::route('website.index')->with('id',$id);
    });

 Route::match(['get', 'post'], '/carreira', 'WebsiteController@jobs')->name('website.jobs');

Route::match(['get', 'post'], '/carreira/{id}', 'WebsiteController@job_open')->name('website.job_open');

Route::match(['get', 'post'], '/quemsomos', 'WebsiteController@about')->name('website.about');

Route::match(['get', 'post'], '/consultoria', 'WebsiteController@consulting')->name('website.consulting');

Route::match(['get', 'post'], '/cursos', 'WebsiteController@courses')->name('website.courses');

Route::match(['get', 'post'], '/atelie', 'WebsiteController@atelie')->name('website.atelie');

Route::match(['get', 'post'], '/portfolio/{id}', 'WebsiteController@portfolio')->name('website.portfolio');

Route::post('/contact', 'WebsiteController@contact')->name('website.contact');
  • I can see your route settings?

  • This way for now.

  • You have read: https://laravel.com/docs/5.7/localization#Configuring-the-locale Your routes are missing configure this. take a look! and a read, it’s hard to talk more than that.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.