PaliTextApi.php 641 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Http\Api;
  3. use App\Models\PaliText;
  4. class PaliTextApi
  5. {
  6. public static function getChapterStartEnd($book, $para)
  7. {
  8. $chapter = PaliText::where('book', $book)
  9. ->where('paragraph', $para)
  10. ->first();
  11. if (! $chapter) {
  12. return false;
  13. }
  14. $start = $para;
  15. $end = $para + $chapter->chapter_len - 1;
  16. return [$start, $end];
  17. }
  18. public static function getChapterPath($book, $para)
  19. {
  20. $path = PaliText::where('book', $book)
  21. ->where('paragraph', $para)
  22. ->value('path');
  23. return $path;
  24. }
  25. }