PaliTextApi.php 664 B

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