Browse Source

add getParent

visuddhinanda 2 weeks ago
parent
commit
c90579dc03
1 changed files with 8 additions and 1 deletions
  1. 8 1
      api-v13/app/Services/PaliTextService.php

+ 8 - 1
api-v13/app/Services/PaliTextService.php

@@ -8,7 +8,14 @@ use Illuminate\Support\Str;
 
 class PaliTextService
 {
-    public function getParent(int $book, int $para) {}
+    public function getParent(int $book, int $para)
+    {
+        $parent = PaliText::where('book', $book)
+            ->where('paragraph',  $para)->value('parent');
+
+        return $parent ? PaliText::where('book', $book)
+            ->where('paragraph',  $parent)->first() : null;
+    }
     public function getCurrChapter(int $book, int $para)
     {
         $paragraph = PaliText::where('book', $book)