shareit/app/Http/Controllers/AlertController.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

38 lines
933 B
PHP

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