Parcourir la source

add articlesInAnthology

visuddhinanda il y a 6 jours
Parent
commit
ff3fd378e5
1 fichiers modifiés avec 9 ajouts et 0 suppressions
  1. 9 0
      api-v12/app/Services/ArticleService.php

+ 9 - 0
api-v12/app/Services/ArticleService.php

@@ -3,6 +3,7 @@
 namespace App\Services;
 namespace App\Services;
 
 
 use App\Models\Article;
 use App\Models\Article;
+use App\Models\ArticleCollection;
 
 
 class ArticleService
 class ArticleService
 {
 {
@@ -37,4 +38,12 @@ class ArticleService
 
 
         return $matches[1] ?? [];
         return $matches[1] ?? [];
     }
     }
+
+    public function articlesInAnthology($anthologyId)
+    {
+        $inCollection = ArticleCollection::where('collect_id', $anthologyId)
+            ->select('article_id')
+            ->get()->toArray();
+        return array_map(fn($item) => $item['article_id'], $inCollection);
+    }
 }
 }