public function back($id) { $data = array('errNum' => 0, 'errMsg' => '', 'errDate' => ''); $borrow = Borrow::find($id); $borrow->status = 1; $book = Book::find($borrow->book_id); $book->book_res = $book->book_res + 1; $book->save(); if ($borrow->update()) { $data['errMsg'] = "归还成功"; return json_encode($data); } else { $data['errMsg'] = "归还失败"; return json_encode($data); } }