public static function getChapterLength($bookName, $chapter) { $latestWord = Word::where('lh', 'like', "{$bookName} {$chapter},%")->orderBy('fh', 'desc')->first()->lh; $wordReferencePattern = "/.*? (\\d+),(\\d+),\\d+/"; $matches = []; preg_match($wordReferencePattern, $latestWord, $matches); return (int) $matches[2]; }
protected function truncate() { Word::truncate(); }
private function findConcordance($wordId) { $concordance = []; $word = Word::find($wordId); $concordance['first'] = $this->createWordRef(Word::where('szal', $word->szal)->groupBy('szal')->first()); $concordance['previous'] = $this->createWordRef(Word::where('szal', $word->szal)->where('fh', '<', $wordId)->orderBy('fh', 'desc')->first()); $concordance['next'] = $this->createWordRef(Word::where('szal', $word->szal)->where('fh', '>', $wordId)->orderBy('fh')->first()); $concordance['nextAlphabetic'] = $this->createWordRef(Word::find($word->fkh)); $concordance['previousAlphabetic'] = $this->createWordRef(Word::find($word->feh)); return $concordance; }
public static function findChapterWords($bookId, $chapter) { $chapterAddress = sprintf("%d%03d", $bookId, $chapter); $words = Word::where('fh', 'like', "{$chapterAddress}%")->with('dictEntry')->orderBy('fh')->get(); return $words; }