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:
2018-10-02 23:53:35 -03:00
parent 8157a183c7
commit 954820f46b
8 changed files with 193 additions and 16 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Auth;
use \App\User;
use \App\Mail\UserWaiting;
use Illuminate\Http\Request;
@@ -11,15 +12,15 @@ class AlertController extends Controller
public function store(Request $request)
{
$item = User::loggedIn()->items()->find(request('item'));
$item->waiting_user_id = \Auth::id();
$item->waiting_user_id = Auth::id();
$item->timestamps = false;
$item->save();
$loggedUser = \Auth::user()->name;
$loggedUser = Auth::user()->name;
$userWithItem = User::find($item->used_by);
\Mail::to($userWithItem)->send(
new UserWaiting($loggedUser, $userWithItem->name, $item)
);
\Mail::to($userWithItem)
->locale($userWithItem->language)
->send(new UserWaiting($loggedUser, $userWithItem->name, $item));
return redirect('home');
}