mirror of
https://github.com/brunofontes/shareit.git
synced 2025-11-15 07:50:54 -03:00
Refactoring
Including some use for classes; REfactoring the HomeController, to make it cleaner and avoid repeating code.
This commit is contained in:
@@ -3,12 +3,22 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Mail;
|
||||
use \App\User;
|
||||
use \App\Mail\UserWaiting;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AlertController extends Controller
|
||||
{
|
||||
/**
|
||||
* Store the waiting_user_id on db
|
||||
* so the user can be alerted when
|
||||
* the item is free
|
||||
*
|
||||
* @param Request $request Form data
|
||||
*
|
||||
* @return redirect to home
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$item = User::loggedIn()->items()->find(request('item'));
|
||||
@@ -18,7 +28,7 @@ class AlertController extends Controller
|
||||
|
||||
$loggedUser = Auth::user()->name;
|
||||
$userWithItem = User::find($item->used_by);
|
||||
\Mail::to($userWithItem)
|
||||
Mail::to($userWithItem)
|
||||
->locale($userWithItem->language)
|
||||
->send(new UserWaiting($loggedUser, $userWithItem->name, $item));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user