mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-27 21:31:27 +00:00
Bruno Fontes
954820f46b
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.
35 lines
609 B
PHP
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();
|
|
}
|
|
}
|