public function levelDel(Request $request) { $level = $request->input("level"); $readerNum = Reader::where('level', '=', $level)->count(); if ($readerNum > 0) { return redirect("/admin/levelManage")->with("msg", "还有用户在此等级,无法删除!"); } $l = Level::find($level); $l->delete(); return redirect("/admin/levelManage")->with("msg", "删除成功!"); }
public function infoSave(Request $request) { $username = $request->session()->get("username"); $user = User::where('username', '=', $username)->first(); if ($user == null) { return redirect('home'); } $reader = Reader::find($user['reader-id']); $reader['reader-name'] = $request->input("reader-name"); $reader['sex'] = $request->input("sex"); $reader['birthday'] = $request->input("birthday"); $reader['phone'] = $request->input('phone'); $reader['mobile'] = $request->input('mobile'); $reader->save(); return redirect('/reader/info'); }
public function readerFoundAction(Request $request) { $id = $request->input('reader-id'); $reader = Reader::find($id); if ($reader == null) { return redirect('/admin/readerFound')->with("msg", "该读者证不存在,请重试!"); } if ($reader['loss'] == false) { return redirect('/admin/readerFound')->with("msg", "该读者证未挂失过!"); } $reader['loss'] = false; $reader->save(); return redirect('/admin/readerFound')->with("msg", "读者证" . $id . "解挂成功!"); }
public function bookBorrowAction(Request $request) { $date = date("Y-m-d"); $reader_id = $request->input("reader-id"); $isbn = $request->input("isbn"); $reader = Reader::find($reader_id); //对输入信息进行检查 if ($reader == null) { return redirect('/admin/bookBorrow')->with("msg", "读者证编号有误,请检查!"); } if ($reader['loss'] == true) { //挂失处理 return redirect('/admin/bookBorrow')->with("msg", "该借书证已挂失,请先解挂后再借书!"); } $book = Book::where("isbn", '=', $isbn)->first(); if ($book == null) { return redirect('/admin/bookBorrow')->with("msg", "图书ISBN有误,请检查!"); } if ($book['quantity-in'] - $book['quantity-out'] - $book['quantity-loss'] < 1) { return redirect('/admin/bookBorrow')->with("msg", "图书数量不足,请检查ISBN!"); } $level = Level::find($reader['level']); $borrowedBookNum = Borrow::where("reader-id", '=', $reader_id)->where("returned", '=', false)->where('loss', '<>', true)->get()->count(); if ($borrowedBookNum >= $level['numbers']) { //借书数量限制 return redirect('/admin/bookBorrow')->with("msg", "该用户借书数量超过限制,请先归还部分图书!"); } $book['quantity-out'] += 1; $book->save(); $borrow = new Borrow(); $shouldReturnDate = date("Y-m-d", strtotime("+" . $level['days'] . " days")); $borrow['reader-id'] = $reader_id; $borrow['book-id'] = $book['book-id']; $borrow['date-borrow'] = $date; $borrow['date-should-return'] = $shouldReturnDate; $borrow->save(); return redirect('/admin/bookBorrow')->with("msg", "借阅成功!"); }