mirror of
https://github.com/brunofontes/shareit.git
synced 2025-11-15 07:50:54 -03:00
Bug Fixed: avoiding item waiting_user across take/return
It happend once: a user asked to be added to the waiting list at the same time other user was returning the item. So the user ended up waiting for the user he was already using.
This commit is contained in:
@@ -22,6 +22,13 @@ class AlertController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$item = User::loggedIn()->items()->find(request('item'));
|
||||
if (!$item->used_by) {
|
||||
session()->flash(
|
||||
FlashMessage::PRIMARY,
|
||||
__('Oh! This item has just being returned. Take it before anyone else!')
|
||||
);
|
||||
return redirect('home');
|
||||
}
|
||||
$item->waiting_user_id = Auth::id();
|
||||
$item->timestamps = false;
|
||||
$item->save();
|
||||
|
||||
Reference in New Issue
Block a user