shareit/app/Http/Controllers/AlertController.php

38 lines
933 B
PHP
Raw Normal View History

2018-09-15 05:09:07 +00:00
<?php
namespace App\Http\Controllers;
use Auth;
2018-09-15 05:09:07 +00:00
use \App\User;
use \App\Mail\UserWaiting;
2018-09-15 05:09:07 +00:00
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();
2018-09-15 05:09:07 +00:00
$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));
2018-09-15 05:09:07 +00:00
return redirect('home');
}
public function delete(Request $request)
{
$item = User::loggedIn()->items()->find(request('item'));
2018-09-15 05:09:07 +00:00
$item->waiting_user_id = null;
$item->timestamps = false;
$item->save();
return redirect('home');
}
}