protected function sendIndexCreateAnswerData($result, $rowCount, $entriesPerPage) { $data = []; foreach ($result as $row) { $rowData = []; $rowData['id'] = $row->getId(); if ($row->getLending() && count($row->getLending()) > 0) { if (count($row->getLending()) > 1) { $this->_logger->log('Inventory is lend multiple times!', 'warning'); } $user = $row->getLending()->first()->getUser(); $rowData['lentUser'] = ['id' => $user->getId(), 'username' => $user->getUsername()]; $rowData['lentUserId'] = $user->getId(); $rowData['lentUserUsername'] = $user->getUsername(); } if ($row->getBook()) { if ($row->getBook()->getSubject()) { $barcode = Babesk\Schbas\Barcode::createByInventory($row); $rowData['barcode'] = $barcode ? $barcode->getAsString() : '???'; $rowData['subjectName'] = $row->getBook()->getSubject()->getName(); } else { $this->_logger->logO('Subject for inventory not found', ['sev' => 'error', 'moreJson' => ['invId' => $row->getId()]]); $rowData['barcode'] = 'Fach nicht gefunden!'; } $rowData['bookTitle'] = $row->getBook()->getTitle(); $rowData['bookIsbn'] = $row->getBook()->getIsbn(); $rowData['bookAuthor'] = $row->getBook()->getAuthor(); } else { $this->_logger->logO('Book for inventory not found', ['sev' => 'error', 'moreJson' => ['invId' => $row->getId()]]); $rowData['barcode'] = 'Buch nicht gefunden!'; } $data['data'][] = $rowData; } $data['pageCount'] = ceil($rowCount / $entriesPerPage); return $data; }