items()->find(request('item')); if ($item->used_by) { return back()->withErrors( Lang::getFromJson("This item is already taken") ); } $item->used_by = Auth::id(); $item->waiting_user_id = null; $item->save(); return redirect('home'); } /** * User return an item * Trigger an event: ReturnItem * * @param Request $request Form data * * @return View home */ public function delete(Request $request) { $item = User::loggedIn()->items()->find(request('item')); event(new ReturnItem($item)); $item->returnItem(); return redirect('home'); } }