Why is the Laravel App :: getLocale () method incompatible?

I use 2 languages ​​in my Laravel 5.2 application. There is a simple password reminder page that I am currently implementing, and for reasons unknown to me, I have problems sending an email for a new password in the correct language.

Say I see a page in German. In the page view, I echo 2 values ​​using Facades:

echo App::getLocale();
echo Session::get('locale');

The page is in German, so both values ​​are echo de.

Now I enter the email address in the form and submit it. The input goes to the controller method and calls the library to send the user a new password:

public function resetPassword() {
    // Validate the input, retrieve the user...    

    Mailer::sendNewPasswordEmail($user); // Call to the library sending emails
}

Finally, in the library, I var_dump the same 2 values, for example:

public static function sendNewPasswordEmail($user) {
    var_dump(App::getLocale());
    var_dump(Session::get('locale'));
    die;
}

Session::get('locale') - de, App::getLocale() en.

, , ?

Blade @lang(). , , , . , , App::getLocale() POST, .

, , . , "" , , . .

?

+4
1

Laravel 5.2 App_Locale . , , - , App:: setLocale() :

<?php namespace App\Http\Middleware;

use Closure;
use Session;
use App;
use Config;

class Locale {

   /**
    * Handle an incoming request.
    *
    * @param  \Illuminate\Http\Request  $request
    * @param  \Closure  $next
    * @return mixed
    */
    public function handle($request, Closure $next)
    {
        App::setLocale(Session::get('locale'));
        return $next($request);
    }

}

Kernel.php

protected $middleware = [
    .
    .
    .

   'App\Http\Middleware\Locale'
];
+4

All Articles