فهرست منبع

add articleChannels

visuddhinanda 5 روز پیش
والد
کامیت
391dba45d2
1فایلهای تغییر یافته به همراه25 افزوده شده و 0 حذف شده
  1. 25 0
      api-v12/app/Services/ArticleService.php

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

@@ -4,8 +4,11 @@ namespace App\Services;
 
 use App\Models\Article;
 use App\Models\ArticleCollection;
+use App\Models\Sentence;
+
 use App\Http\Resources\ArticleResource;
 use Illuminate\Support\Facades\Log;
+use App\Http\Api\ChannelApi;
 
 class ArticleService
 {
@@ -62,4 +65,26 @@ class ArticleService
             'ok' => true
         ];
     }
+
+    public function articleChannels(string $id): array
+    {
+        $sentences = $this->sentenceIds($id);
+        $query = [];
+        foreach ($sentences as $value) {
+            $ids = explode('-', $value);
+            $query[] = $ids;
+        }
+        $fields = ['book_id', 'paragraph', 'word_start', 'word_end'];
+        $publicChannelIds = Sentence::whereIns($fields, $query)
+            ->where('strlen', '>', 0)
+            ->where('status', 30)
+            ->groupBy('channel_uid')
+            ->select('channel_uid')
+            ->get();
+        $channels = [];
+        foreach ($publicChannelIds as  $id) {
+            $channels = ChannelApi::getById($id);
+        }
+        return $channels;
+    }
 }