mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-28 05:41:27 +00:00
37 lines
902 B
PHP
37 lines
902 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use \App\User;
|
|
use \App\Mail\UserWaiting;
|
|
use Illuminate\Http\Request;
|
|
|
|
class AlertController extends Controller
|
|
{
|
|
public function store(Request $request)
|
|
{
|
|
$item = User::find(\Auth::id())->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)->send(
|
|
new UserWaiting($loggedUser, $userWithItem->name, $item)
|
|
);
|
|
|
|
return redirect('home');
|
|
}
|
|
|
|
public function delete(Request $request)
|
|
{
|
|
$item = User::find(\Auth::id())->items()->find(request('item'));
|
|
$item->waiting_user_id = null;
|
|
$item->timestamps = false;
|
|
$item->save();
|
|
|
|
return redirect('home');
|
|
}
|
|
}
|