소스 검색

add getParent

visuddhinanda 2 주 전
부모
커밋
c90579dc03
1개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  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)