mirror of
https://github.com/brunofontes/shareit.git
synced 2025-11-15 16:00:54 -03:00
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.
This commit is contained in:
20
app/User.php
20
app/User.php
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
@@ -46,6 +47,23 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
*/
|
||||
public static function loggedIn()
|
||||
{
|
||||
return (new static)->findOrFail(\Auth::id());
|
||||
return (new static)->findOrFail(Auth::id());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default website language
|
||||
* for the acual user
|
||||
*
|
||||
* @param string $language The language code
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setLanguage(string $language)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
$user = self::loggedIn();
|
||||
$user->language = $language;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user