private function createWordRef($word) { if ($word !== null) { $wordId = $word->fh; $ref['id'] = $wordId; $matches = []; preg_match("/^(\\d{1,3}?)(\\d{3})(\\d{3})(\\d{5})\$/", $wordId, $matches); $ref['bookId'] = (int) $matches[1]; $ref['bookName'] = Book::findById($ref['bookId'])->nev; $ref['chapter'] = (int) $matches[2]; $ref['verse'] = (int) $matches[3]; $ref['wordNum'] = (int) $matches[4]; return $ref; } else { return null; } }
public function getChapterLength($bookId, $chapter) { $book = Book::findById($bookId); return Response::json(['bookLength' => Book::getBookLength($book->nev), 'chapterLength' => Book::getChapterLength($book->nev, $chapter)]); }