Exemplo n.º 1
0
 public function overTime(Request $request)
 {
     $num = 10;
     $username = $request->session()->get("username");
     $borrows = Borrow::where("date-should-return", "<", DB::raw("curdate()"))->paginate($num);
     return view("/admin/OverTime", ['username' => $username, "borrows" => $borrows]);
 }
Exemplo n.º 2
0
 public function history(Request $request)
 {
     $num = 10;
     $username = $request->session()->get("username");
     $user = User::where('username', '=', $username)->first();
     if ($user == null) {
         return redirect('/reader/home');
     }
     $borrows = Borrow::where('reader-id', '=', $user['reader-id'])->orderBy('id')->paginate($num);
     return view('/reader/history', ['username' => $username, 'borrows' => $borrows]);
 }
Exemplo n.º 3
0
 public function bookLossAction(Request $request)
 {
     $reader_id = $request->input("reader-id");
     $isbn = $request->input("isbn");
     $book = Book::where("isbn", '=', $isbn)->first();
     if ($book == null) {
         return redirect('/admin/bookLoss')->with("msg", "读者证编号有误,请检查!");
     }
     if ($book['quantity-out'] + $book['quantity-loss'] + 1 > $book['quantity-in']) {
         return redirect('/admin/bookLoss')->with("msg", "图书信息有误,请检查!");
     }
     $borrow = Borrow::where("reader-id", '=', $reader_id)->where("book-id", '=', $book['book-id'])->where("returned", '=', 0)->first();
     if ($borrow == null) {
         return redirect('/admin/bookLoss')->with("msg", "信息有误,请检查!");
     }
     $book['quantity-out'] = $book['quantity-out'] - 1;
     $book['quantity-Loss'] += 1;
     $book->save();
     $borrow['loss'] = true;
     $borrow->save();
     return redirect('/admin/bookLoss')->with("msg", "图书挂失成功!");
 }