shareit/app/Listeners/SetLanguage.php
Bruno Fontes 675200303a Added: language to User profile (DB)
The language were set only on session. But now it is
stored with user profile, on DB.

It is important as now I can send alert e-mails to each
user on their own languages and not the activer
user language.

Also, wherever the user logs out and logs in again,
it will see the same site locale.
2018-10-02 23:53:35 -03:00

35 lines
609 B
PHP

<?php
namespace App\Listeners;
use App\User;
use IlluminateAuthEventsLogin;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Auth\Events\Login;
class SetLanguage
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param IlluminateAuthEventsLogin $event
* @return void
*/
public function handle(Login $event)
{
session(['lang' => User::loggedIn()->language]);
session()->save();
}
}