Explorar el Código

add getParent

visuddhinanda hace 2 semanas
padre
commit
c90579dc03
Se han modificado 1 ficheros con 8 adiciones y 1 borrados
  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)