visuddhinanda 2 ヶ月 前
コミット
263db61f22
63 ファイル変更2828 行追加0 行削除
  1. 19 0
      api-v12/app/Http/Resources/AiAssistant.php
  2. 24 0
      api-v12/app/Http/Resources/AiAssistantResource.php
  3. 22 0
      api-v12/app/Http/Resources/AiModelResource.php
  4. 53 0
      api-v12/app/Http/Resources/ArticleMapResource.php
  5. 19 0
      api-v12/app/Http/Resources/ArticleNavResource.php
  6. 216 0
      api-v12/app/Http/Resources/ArticleResource.php
  7. 58 0
      api-v12/app/Http/Resources/AttachmentResource.php
  8. 19 0
      api-v12/app/Http/Resources/BookTitleResource.php
  9. 38 0
      api-v12/app/Http/Resources/ChannelResource.php
  10. 19 0
      api-v12/app/Http/Resources/ChapterResource.php
  11. 32 0
      api-v12/app/Http/Resources/ChatMessageResource.php
  12. 28 0
      api-v12/app/Http/Resources/ChatResource.php
  13. 22 0
      api-v12/app/Http/Resources/CollectionListResource.php
  14. 50 0
      api-v12/app/Http/Resources/CollectionResource.php
  15. 19 0
      api-v12/app/Http/Resources/CompoundResource.php
  16. 44 0
      api-v12/app/Http/Resources/CourseMemberResource.php
  17. 125 0
      api-v12/app/Http/Resources/CourseResource.php
  18. 19 0
      api-v12/app/Http/Resources/DictInfoResource.php
  19. 34 0
      api-v12/app/Http/Resources/DictPreferenceResource.php
  20. 19 0
      api-v12/app/Http/Resources/DictVocabularyResource.php
  21. 36 0
      api-v12/app/Http/Resources/DiscussionCountResource.php
  22. 58 0
      api-v12/app/Http/Resources/DiscussionResource.php
  23. 34 0
      api-v12/app/Http/Resources/GroupMemberResource.php
  24. 55 0
      api-v12/app/Http/Resources/GroupResource.php
  25. 19 0
      api-v12/app/Http/Resources/InviteResource.php
  26. 32 0
      api-v12/app/Http/Resources/LikeResource.php
  27. 19 0
      api-v12/app/Http/Resources/MilestoneResource.php
  28. 19 0
      api-v12/app/Http/Resources/ModelLogResource.php
  29. 26 0
      api-v12/app/Http/Resources/NavCSParaResource.php
  30. 19 0
      api-v12/app/Http/Resources/NavPageResource.php
  31. 49 0
      api-v12/app/Http/Resources/NissayaEndingResource.php
  32. 131 0
      api-v12/app/Http/Resources/NotificationResource.php
  33. 19 0
      api-v12/app/Http/Resources/PaliTextResource.php
  34. 39 0
      api-v12/app/Http/Resources/ProjectResource.php
  35. 67 0
      api-v12/app/Http/Resources/RecentResource.php
  36. 38 0
      api-v12/app/Http/Resources/RelatedParagraphResource.php
  37. 71 0
      api-v12/app/Http/Resources/RelationResource.php
  38. 58 0
      api-v12/app/Http/Resources/SearchBookResource.php
  39. 57 0
      api-v12/app/Http/Resources/SearchPaliWbwResource.php
  40. 68 0
      api-v12/app/Http/Resources/SearchResource.php
  41. 24 0
      api-v12/app/Http/Resources/SearchTitleIndexResource.php
  42. 31 0
      api-v12/app/Http/Resources/SearchTitleResource.php
  43. 42 0
      api-v12/app/Http/Resources/SentHistoryResource.php
  44. 45 0
      api-v12/app/Http/Resources/SentPrResource.php
  45. 87 0
      api-v12/app/Http/Resources/SentResource.php
  46. 34 0
      api-v12/app/Http/Resources/SentSimResource.php
  47. 43 0
      api-v12/app/Http/Resources/SentenceAttachmentResource.php
  48. 92 0
      api-v12/app/Http/Resources/ShareResource.php
  49. 53 0
      api-v12/app/Http/Resources/TagMapResource.php
  50. 19 0
      api-v12/app/Http/Resources/TagResource.php
  51. 80 0
      api-v12/app/Http/Resources/TaskResource.php
  52. 132 0
      api-v12/app/Http/Resources/TermResource.php
  53. 19 0
      api-v12/app/Http/Resources/TermVocabularyResource.php
  54. 62 0
      api-v12/app/Http/Resources/TocResource.php
  55. 44 0
      api-v12/app/Http/Resources/TransferResource.php
  56. 53 0
      api-v12/app/Http/Resources/UserDictResource.php
  57. 39 0
      api-v12/app/Http/Resources/UserResource.php
  58. 19 0
      api-v12/app/Http/Resources/ViewResource.php
  59. 28 0
      api-v12/app/Http/Resources/VocabularyResource.php
  60. 19 0
      api-v12/app/Http/Resources/WbwResource.php
  61. 19 0
      api-v12/app/Http/Resources/WbwTemplateResource.php
  62. 32 0
      api-v12/app/Http/Resources/WebHookResource.php
  63. 19 0
      api-v12/app/Http/Resources/WordIndexResource.php

+ 19 - 0
api-v12/app/Http/Resources/AiAssistant.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class AiAssistant extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 24 - 0
api-v12/app/Http/Resources/AiAssistantResource.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class AiAssistantResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            'id' => $this->uid,
+            'userName' => $this->real_name,
+            'nickName' => $this->name,
+        ];
+        return $data;
+    }
+}

+ 22 - 0
api-v12/app/Http/Resources/AiModelResource.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\AiAssistantApi;
+
+class AiModelResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = parent::toArray($request);
+        $data['user'] = AiAssistantApi::userInfo($this);
+        return $data;
+    }
+}

+ 53 - 0
api-v12/app/Http/Resources/ArticleMapResource.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\UserApi;
+use App\Http\Api\MdRender;
+use App\Models\Collection;
+
+class ArticleMapResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            'id' => $this->id,
+            "collect_id" => $this->collect_id,
+            "article_id" => $this->article_id,
+            "level" => $this->level,
+            "title" => $this->title,
+            "editor"=> UserApi::getById($this->editor_id),
+            "children" => $this->children,
+            'status' => $this->status,
+            "deleted_at" => $this->deleted_at,
+            "created_at" => $this->created_at,
+            "updated_at" => $this->updated_at,
+        ];
+        $channels = [];
+        if($request->has('channel')){
+            $channels = explode('_',$request->get('channel')) ;
+        }else{
+            $defaultChannel = Collection::where('uid',$this->collect_id)->value('default_channel');
+            if($defaultChannel){
+                $channels[] = $defaultChannel;
+            }
+        }
+        $mdRender = new MdRender(['format'=>'simple']);
+        $data['title_text'] = $mdRender->convert($this->title,$channels);
+        if ($request->get('view') === 'article') {
+            $collection = Collection::where('uid',$this->collect_id)->first();
+            if($collection){
+                $data['collection']['id']=$collection->uid;
+                $data['collection']['title']=$collection->title;
+            }
+        }
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/ArticleNavResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class ArticleNavResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 216 - 0
api-v12/app/Http/Resources/ArticleResource.php

@@ -0,0 +1,216 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Str;
+
+use App\Models\CourseMember;
+use App\Models\Course;
+use App\Models\Collection;
+use App\Models\ArticleCollection;
+use App\Models\Channel;
+
+use App\Http\Controllers\ArticleController;
+
+use App\Http\Api\MdRender;
+use App\Http\Api\UserApi;
+use App\Http\Api\StudioApi;
+use App\Http\Api\AuthApi;
+use App\Http\Api\ChannelApi;
+
+
+class ArticleResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "uid" => $this->uid,
+            "title" => $this->title,
+            "subtitle" => $this->subtitle,
+            "summary" => $this->summary,
+            "studio"=> StudioApi::getById($this->owner),
+            "editor"=> UserApi::getById($this->editor_id),
+            "status" => $this->status,
+            "lang" => $this->lang,
+            "parent_uid" => $this->parent,
+            "created_at" => $this->created_at,
+            "updated_at" => $this->updated_at,
+        ];
+
+        $user = AuthApi::current($request);
+        if($user){
+            $canEdit = ArticleController::userCanEdit($user['user_uid'],$this);
+            if($canEdit){
+                $data['role'] = 'editor';
+            }
+        }
+
+        //查询该文章在哪些文集中出现
+        $collectionCount = ArticleCollection::where('article_id',$this->uid)->count();
+        if($collectionCount>0){
+            $data['anthology_count'] = $collectionCount;
+            $collection = ArticleCollection::where('article_id',$this->uid)->first();
+            $data['anthology_first'] = Collection::find($collection->collect_id);
+        }
+        if($request->has('anthology') && Str::isUuid($request->get('anthology'))){
+            $anthology = Collection::where('uid',$request->get('anthology'))->first();
+        }
+        //渲染简化版标题
+        $channels = [];
+        if($request->has('channel')){
+            //有channel
+            $channels = explode('_',$request->get('channel')) ;
+        }else if(isset($anthology) && $anthology && !empty($anthology->default_channel)){
+            //没有channel,使用文集channel
+            $channels[] = $anthology->default_channel;
+        }
+        $mdRender = new MdRender(['format'=>'simple']);
+
+        //path
+        if($request->has('anthology') && Str::isUuid($request->get('anthology'))){
+            $data['path'] = array();
+            if(isset($anthology) && $anthology){
+                $data['path'][] = ['key'=>$anthology->uid,
+                            'title'=>$anthology->title,
+                            'level'=>0];
+            }
+
+            $currLevel = -1;
+            $aList = ArticleCollection::where('collect_id',$request->get('anthology'))
+                                                ->orderBy('id','desc')
+                                                ->select(['article_id','title','level'])->get();
+            $path = array();
+            foreach ($aList as $article) {
+                if($article->article_id === $this->uid ||
+                ($currLevel >= 0 && $article->level < $currLevel)){
+                    $currLevel = $article->level;
+                    $path[] = ['key'=>$article->article_id,
+                                'title'=>$mdRender->convert($article->title,$channels),
+                                'level'=>$article->level];
+                }
+            }
+            for ($i=count($path)-1; $i >=0 ; $i--) {
+                $data['path'][] = $path[$i];
+            }
+
+            //下级目录
+            $level = -1;
+            $subToc = array();
+            for ($i=count($aList)-1; $i >=0 ; $i--) {
+                $article = $aList[$i];
+                if($level>=0){
+                    if($article->level>$level){
+                        $subToc[] =[
+                            "key"=>$article->article_id,
+                            "title"=>$mdRender->convert($article->title,$channels),
+                            "level"=>$article->level
+                        ];
+                    }else{
+                        break;
+                    }
+                }
+                if($article->article_id === $this->uid){
+                    $level = $article->level;
+                }
+            }
+            $data['toc'] = $subToc;
+        }
+
+
+        $data['title_text'] = $mdRender->convert($this->title,$channels);
+
+        //render html
+        $channels = array();
+        if(isset($this->content) && !empty($this->content)){
+            if($request->has('channel')){
+                $channels = explode('_',$request->get('channel')) ;
+            }else if($request->has('anthology')){
+                $defaultChannel = Collection::where('uid',$request->get('anthology'))
+                                    ->value('default_channel');
+                if($defaultChannel){
+                    $channels[] = $defaultChannel;
+                }
+            }
+            if(count($channels) === 0){
+                //查找用户默认channel
+                $studioChannel = Channel::where('owner_uid',$this->owner)
+                                        ->where('type','translation')
+                                        ->get();
+                if($studioChannel){
+                    $channelId = $studioChannel[0]->uid;
+                    $channels = [$channelId];
+                }else{
+                    $channelId = ChannelApi::getSysChannel('_community_translation_'.strtolower($this->lang).'_',
+                                                        '_community_translation_en_');
+                    if($channelId){
+                        $channels = [$channelId];
+                    }
+                }
+            }
+            $data["content"] = $this->content;
+            $data["content_type"] = $this->content_type;
+            $query_id = null;
+            if($request->has('course')){
+                if($request->has('exercise')){
+                    $query_id = $request->get('exercise');
+                    if($request->has('user')){
+                        /**
+                         * 显示指定用户作业
+                         * 查询用户在课程中的channel
+                         */
+                        $userId = UserApi::getIdByName($request->get('user'));
+
+                        $userInCourse = CourseMember::where('course_id',$request->get('course'))
+                                    ->where('user_id',$userId)
+                                    ->first();
+                        if($userInCourse){
+                            $channelId = $userInCourse->channel_id;
+                            $channels = [$channelId];
+                        }
+                    }else if($request->get('view')==="answer"){
+                        /**
+                         * 显示答案
+                         * 算法:查询course 答案 channel
+                         */
+                        $channelId = Course::where('id',$request->get('course'))->value('channel_id');
+                        $channels = [$channelId];
+                    }else{
+                        //显示答案
+                        $channelId = Course::where('id',$request->get('course'))->value('channel_id');
+                        $channels = [$channelId];
+                    }
+                }else{
+                    $channelId = Course::where('id',$request->get('course'))->value('channel_id');
+                    $channels = [$channelId];
+                }
+            }
+
+            $mode = $request->get('mode','read');
+            $format = $request->get('format','react');
+
+            $htmlRender = new MdRender([
+                'mode' => $mode,
+                'format'=> $format,
+                'footnote' => true,
+                'origin' => $request->get('origin',true),
+                'paragraph' => $request->get('paragraph',false),
+            ]);
+            //Log::debug('article render',['content'=>$this->content,'format'=>$format,'html'=>$html]);
+            $data["html"] = $htmlRender->convert($this->content,$channels);
+            if(empty($this->summary)){
+                $data["_summary"] = MdRender::render($this->content,
+                                                    $channels,$query_id,$mode,
+                                                    'translation','markdown','text');
+            }
+        }
+        return $data;
+    }
+}

+ 58 - 0
api-v12/app/Http/Resources/AttachmentResource.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Facades\App;
+
+class AttachmentResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $filename = $this->bucket . '/' . $this->name;
+        $data = [
+            "id" => $this->id,
+            "user_uid" => $this->user_uid,
+            "name" => $filename,
+            "filename" => $filename,
+            "title" => $this->title,
+            "size" => $this->size,
+            "content_type" => $this->content_type,
+            "status" => $this->status,
+            "created_at" => $this->created_at,
+            "updated_at" => $this->updated_at,
+        ];
+
+        if (App::environment('local')) {
+            $data['url'] = Storage::url($filename);
+        } else {
+            $data['url'] = Storage::temporaryUrl($filename, now()->addDays(2));
+        }
+
+        $type = explode('/', $this->content_type);
+        if ($type[0] === 'image' || $type[0] === 'video') {
+            $path_parts = pathinfo($this->name);
+            $small = $this->bucket . '/' . $path_parts['filename'] . '_s.jpg';
+            $middle = $this->bucket . '/' . $path_parts['filename'] . '_m.jpg';
+            if (App::environment('local')) {
+                $data['thumbnail'] = [
+                    'small' => Storage::url($small),
+                    'middle' => Storage::url($middle),
+                ];
+            } else {
+                $data['thumbnail'] = [
+                    'small' => Storage::temporaryUrl($small, now()->addDays(2)),
+                    'middle' => Storage::temporaryUrl($middle, now()->addDays(2)),
+                ];
+            }
+        }
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/BookTitleResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class BookTitleResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 38 - 0
api-v12/app/Http/Resources/ChannelResource.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\StudioApi;
+
+class ChannelResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "uid" => $this->uid,
+            "name" => $this->name,
+            "summary" => $this->summary,
+            "type" => $this->type,
+            "studio" => StudioApi::getById($this->owner_uid),
+            "lang" => $this->lang,
+            "is_system" => $this->is_system,
+            "status" => $this->status,
+            "created_at" => $this->created_at,
+            "updated_at" => $this->updated_at,
+        ];
+        if (isset($this->progress)) {
+            $data["progress"] = $this->progress;
+        }
+        if (isset($this->role)) {
+            $data["role"] = $this->role;
+        }
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/ChapterResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class ChapterResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 32 - 0
api-v12/app/Http/Resources/ChatMessageResource.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class ChatMessageResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return [
+            'id' => $this->uid,
+            'chat_id' => $this->chat_id,
+            'parent_id' => $this->parent_id,
+            'session_id' => $this->session_id,
+            'role' => $this->role,
+            'content' => $this->content,
+            'model_name' => $this->model_name,
+            'tool_calls' => $this->tool_calls,
+            'tool_call_id' => $this->tool_call_id,
+            'is_active' => $this->is_active,
+            'created_at' => $this->created_at,
+            'updated_at' => $this->updated_at,
+        ];
+    }
+}

+ 28 - 0
api-v12/app/Http/Resources/ChatResource.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class ChatResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return [
+            'id' => $this->uid,
+            'title' => $this->title,
+            'user_id' => $this->user_id,
+            'created_at' => $this->created_at,
+            'updated_at' => $this->updated_at,
+            'messages_count' => $this->when($this->relationLoaded('messages'), function () {
+                return $this->messages->count();
+            }),
+        ];
+    }
+}

+ 22 - 0
api-v12/app/Http/Resources/CollectionListResource.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class CollectionListResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return [
+            'id' => $this->uid,
+            'title' => $this->title,
+        ];
+    }
+}

+ 50 - 0
api-v12/app/Http/Resources/CollectionResource.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\StudioApi;
+use App\Http\Api\ChannelApi;
+use App\Models\ArticleCollection;
+
+
+class CollectionResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "uid" => $this->uid,
+            "title" => $this->title,
+            "subtitle" => $this->subtitle,
+            "summary" => $this->summary,
+            "studio" => StudioApi::getById($this->owner),
+            "childrenNumber" => ArticleCollection::where('collect_id',$this->uid)->count(),
+            "status" => $this->status,
+            'lang' => $this->lang,
+            "created_at" => $this->created_at,
+            "updated_at" => $this->updated_at,
+        ];
+        $channel = ChannelApi::getById($this->default_channel);
+        if($channel){
+            $data['default_channel'] = $channel;
+        }
+        if($this->fullArticleList===true){
+            $data["article_list"] = \json_decode($this->article_list);
+        }else{
+            if(isset($this->article_list) && !empty($this->article_list) ){
+                $arrList = \json_decode($this->article_list);
+                if(is_array($arrList)){
+                    $data["article_list"] = array_slice($arrList,0,4);
+                }
+            }
+        }
+
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/CompoundResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class CompoundResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 44 - 0
api-v12/app/Http/Resources/CourseMemberResource.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\UserApi;
+use App\Http\Api\ChannelApi;
+use App\Models\Course;
+
+class CourseMemberResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "id"=>$this->id,
+            "user_id"=> $this->user_id,
+            "course_id"=> $this->course_id,
+            "role"=> $this->role ,
+            "user"=> UserApi::getByUuid($this->user_id),
+            "editor"=> UserApi::getByUuid($this->editor_uid),
+            "status"=> $this->status,
+            'channel_id'=> $this->channel_id,
+            "created_at"=> $this->created_at,
+            "updated_at"=> $this->updated_at,
+        ];
+        if($this->channel_id){
+            $channel = ChannelApi::getById($this->channel_id);
+            if($channel){
+               $data['channel'] =  $channel;
+            }
+        }
+        if(!empty($request->get('request_course'))){
+            $course = Course::find($this->course_id);
+            $data['course'] =  $course;
+        }
+        return $data;
+    }
+}

+ 125 - 0
api-v12/app/Http/Resources/CourseResource.php

@@ -0,0 +1,125 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\UserApi;
+use App\Http\Api\StudioApi;
+use App\Models\Collection;
+use App\Models\Channel;
+use App\Models\CourseMember;
+use App\Http\Api\AuthApi;
+use App\Models\Attachment;
+use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Str;
+use Illuminate\Support\Facades\App;
+
+class CourseResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "id"=>$this->id,
+            "title"=> $this->title,
+            "subtitle"=> $this->subtitle,
+            "summary"=> $this->summary,
+            "sign_up_message"=> $this->sign_up_message,
+            "teacher"=> UserApi::getByUuid($this->teacher),
+            "course_count"=>10,
+            "publicity"=> $this->publicity,
+            "start_at"=> $this->start_at,
+            "end_at"=> $this->end_at,
+            "sign_up_start_at"=> $this->sign_up_start_at,
+            "sign_up_end_at"=> $this->sign_up_end_at,
+            "content"=> $this->content,
+            "content_type"=> $this->content_type,
+            "cover"=> $this->cover,
+            "channel_id"=>$this->channel_id,
+            "join"=> $this->join,
+            "number"=> $this->number,
+            "request_exp"=> $this->request_exp,
+            "studio" => StudioApi::getById($this->studio_id),
+            "created_at"=> $this->created_at,
+            "updated_at"=> $this->updated_at,
+        ];
+        $data['member_count'] = CourseMember::where('course_id',$this->id)
+                                            ->where('is_current',true)->count();
+
+        $data['members'] = CourseMember::where('course_id',$this->id)
+                                        ->where('is_current',true)
+                                        ->select(['role','status'])
+                                        ->get();
+        $user = AuthApi::current($request);
+        if($user){
+            $data['my_role'] = CourseMember::where('course_id',$this->id)
+                                            ->where('is_current',true)
+                                            ->where('user_id',$user['user_uid'])
+                                            ->value('role');
+        }
+
+        if($this->cover){
+            $thumb = str_replace('.jpg','_m.jpg',$this->cover);
+            if (App::environment('local')) {
+                $data['cover_url'] = [Storage::url($this->cover),Storage::url($thumb)];
+            }else{
+                $data['cover_url'] = [
+                    Storage::temporaryUrl($this->cover, now()->addDays(6)),
+                    Storage::temporaryUrl($thumb, now()->addDays(6)),
+                ];
+            }
+        }
+        if(Str::isUuid($this->cover)){
+            $coverId = Attachment::find($this->cover);
+            $cover_url = [];
+            if($coverId){
+                $cover_url[] = Storage::disk('public')->url($coverId->bucket.'/'.$coverId->name);
+                $cover_url[] = Storage::disk('public')->url($coverId->bucket.'/'.$coverId->id.'_s.jpg');
+                $cover_url[] = Storage::disk('public')->url($coverId->bucket.'/'.$coverId->id.'_m.jpg');
+                $cover_url[] = Storage::disk('public')->url($coverId->bucket.'/'.$coverId->id.'_l.jpg');
+                $data['cover_url'] = $cover_url;
+            }
+        }
+
+        $textbook = Collection::where('uid',$this->anthology_id)->select(['uid','title','owner'])->first();
+        if($textbook){
+            $data['anthology_id'] = $textbook->uid;
+            $data['anthology_title'] = $textbook->title;
+            $data['anthology_owner'] = StudioApi::getById($textbook->owner);
+        }
+        if(!empty($this->channel_id)){
+            $channel = Channel::where('uid',$this->channel_id)->select(['name','owner_uid'])->first();
+            if($channel){
+                $data['channel_name'] = $channel->name;
+                $data['channel_owner'] = StudioApi::getById($channel->owner_uid);
+            }
+        }
+
+        if($request->get('view') === "study" || $request->get('view') === "teach"){
+            $user = AuthApi::current($request);
+            if($user){
+                $course_member = CourseMember::where('user_id',$user["user_uid"])
+                                    ->where('course_id',$this->id)
+                                    ->where('is_current',true)
+                                    ->first();
+                if($course_member){
+                    $data['my_status'] = $course_member->status;
+                    $data['my_status_id'] = $course_member->id;
+                }
+            }
+        }else{
+            //计算待审核
+            $data['count_progressing'] = CourseMember::where('course_id',$this->id)
+                                                ->where('status',"invited")
+                                                ->where('is_current',true)
+                                                ->count();
+        }
+
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/DictInfoResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class DictInfoResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 34 - 0
api-v12/app/Http/Resources/DictPreferenceResource.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\UserApi;
+
+class DictPreferenceResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            'id' => strval($this->id),
+            'word' => $this->word,
+            'count' => $this->count,
+            'parent' => $this->parent,
+            'note' => $this->note,
+            'factors' => $this->factors,
+            'confidence' => $this->confidence,
+            'updated_at' => $this->updated_at,
+            'creator_id' => $this->creator_id,
+        ];
+        if (!empty($this->editor_id)) {
+            $data['editor'] = UserApi::getByUuid($this->editor_id);
+        }
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/DictVocabularyResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class DictVocabularyResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 36 - 0
api-v12/app/Http/Resources/DiscussionCountResource.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\Wbw;
+
+class DiscussionCountResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            'id' => $this->id,
+            'res_id' => $this->res_id,
+            'res_type' => $this->res_type,
+            'type' => $this->type,
+            'editor_uid' => $this->editor_uid
+        ];
+
+        switch ($this->res_type) {
+            case 'wbw':
+                $wbw = Wbw::where('uid',$this->res_id)
+                        ->select(['book_id','paragraph','wid'])
+                        ->first();
+                $data['wbw'] = $wbw;
+                break;
+        }
+        return $data;
+    }
+}

+ 58 - 0
api-v12/app/Http/Resources/DiscussionResource.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace App\Http\Resources;
+use App\Http\Api\UserApi;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\Discussion;
+use App\Models\Sentence;
+use Illuminate\Support\Str;
+use App\Http\Api\MdRender;
+
+class DiscussionResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+
+        $data = [
+            "id"=>$this->id,
+            "title"=> $this->title,
+            "content"=> $this->content,
+            "content_type"=> $this->content_type,
+            "parent"=> $this->parent,
+            "status"=> $this->status,
+            "editor"=> UserApi::getByUuid($this->editor_uid),
+            "res_id"=>$this->res_id,
+            "res_type"=> $this->res_type,
+            "type"=> $this->type,
+            "tpl_id"=> $this->tpl_id,
+            'children_count' => Discussion::where('parent',$this->id)->count(),
+            "created_at"=> $this->created_at,
+            "updated_at"=> $this->updated_at,
+        ];
+        $channels = array();
+        switch ($this->res_type) {
+            case 'sentence':
+                $channelId = Sentence::where('uid',$this->res_id)->value('channel_uid');
+                if(Str::isUuid($channelId)){
+                    $channels[] = $channelId;
+                }
+                break;
+            default:
+                # code...
+                break;
+        }
+        if(count($channels)>0){
+            $data["html"] = MdRender::render($this->content,$channels,null,'read');
+            $data["summary"] = MdRender::render($this->content,$channels,null,'read','translation','markdown','text');
+        }
+
+        return $data;
+    }
+}

+ 34 - 0
api-v12/app/Http/Resources/GroupMemberResource.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Http\Resources;
+
+use App\Http\Api\UserApi;
+use App\Http\Api\GroupApi;
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class GroupMemberResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $roles = ["owner", "manager", "member"];
+        return [
+            "id" => $this->id,
+            "user_id" => $this->user_id,
+            "group_id" => $this->group_id,
+            'group' => GroupApi::getById($this->group_id),
+            "power" => $this->power,
+            'role' => $roles[$this->power],
+            "level" => $this->level,
+            "status" => $this->status,
+            "user" => UserApi::getByUuid($this->user_id),
+            "created_at" => $this->created_at,
+            "updated_at" => $this->updated_at,
+        ];
+    }
+}

+ 55 - 0
api-v12/app/Http/Resources/GroupResource.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\GroupMember;
+use App\Http\Api\AuthApi;
+use App\Http\Api\StudioApi;
+
+class GroupResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+		$data = [
+            'uid' => $this->uid,
+            'name' => $this->name,
+            'description' => $this->description,
+            'owner' => $this->owner,
+            "studio" => StudioApi::getById($this->owner),
+            'updated_at' => $this->updated_at,
+            'created_at' => $this->created_at
+        ];
+        $user = AuthApi::current($request);
+        if($user){
+            if($this->owner === $user['user_uid']){
+                $data['role'] = 'owner';
+            }else{
+                $power = GroupMember::where('user_id',$user['user_uid'])
+                                      ->where('group_id',$this->uid)
+                                      ->value('power');
+                switch ($power) {
+                    case 0:
+                        $data['role'] = 'owner';
+                        break;
+                    case 1:
+                        $data['role'] = 'manager';
+                        break;
+                    case 2:
+                        $data['role'] = 'member';
+                        break;
+                    default:
+                        $data['role'] = 'unknown';
+                        break;
+                }
+            }
+        }
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/InviteResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class InviteResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 32 - 0
api-v12/app/Http/Resources/LikeResource.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\UserApi;
+
+class LikeResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            'id' => $this->id,
+            'type' => $this->type,
+            'target_id' => $this->target_id,
+            'target_type' => $this->target_type,
+            'context' => $this->context,
+            'updated_at' => $this->updated_at,
+            'created_at' => $this->created_at
+        ];
+        if($this->user_id){
+            $data['user'] = UserApi::getByUuid($this->user_id);
+        }
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/MilestoneResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class MilestoneResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/ModelLogResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class ModelLogResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 26 - 0
api-v12/app/Http/Resources/NavCSParaResource.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\PaliText;
+
+class NavCSParaResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [];
+        $data['content'] = PaliText::where('book',$this->book)
+                                ->where('paragraph',$this->paragraph)
+                                ->value('text');
+        $data['book'] = $this->book;
+        $data['start'] = $this->paragraph;
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/NavPageResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class NavPageResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 49 - 0
api-v12/app/Http/Resources/NissayaEndingResource.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\UserApi;
+use App\Http\Api\ChannelApi;
+use App\Models\DhammaTerm;
+
+class NissayaEndingResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "id"=>$this->id,
+            "ending"=> $this->ending,
+            "lang"=> $this->lang,
+            "relation"=> $this->relation,
+            "case"=> $this->case,
+            "from"=> json_decode($this->from),
+            "count"=> $this->count,
+            "editor"=> UserApi::getByUuid($this->editor_id),
+            "created_at"=> $this->created_at,
+            "updated_at"=> $this->updated_at,
+        ];
+
+        if($this->lang === 'my'){
+            $uiLang = strtolower($request->get('ui-lang','en')) ;
+            $term_channel = ChannelApi::getSysChannel("_System_Grammar_Term_{$uiLang}_");
+            if($term_channel){
+                $term = DhammaTerm::where("word",$this->ending)
+                                            ->where('channal',$term_channel)
+                                            ->first();
+                $data['term_channel'] = $term_channel;
+                if($term){
+                    $data['term_id'] = $term->guid;
+                }
+            }
+        }
+
+        return $data;
+    }
+}

+ 131 - 0
api-v12/app/Http/Resources/NotificationResource.php

@@ -0,0 +1,131 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use Illuminate\Support\Facades\Log;
+
+use App\Models\SentPr;
+use App\Models\Wbw;
+use App\Models\Discussion;
+use App\Models\Sentence;
+
+use App\Http\Api\UserApi;
+use App\Http\Api\PaliTextApi;
+use App\Http\Api\ChannelApi;
+
+class NotificationResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "id" => $this->id,
+            "from" => UserApi::getByUuid($this->from),
+            "to" => UserApi::getByUuid($this->to),
+            "url" => $this->url,
+            "content" => $this->content,
+            "content_type" => $this->content_type,
+            "res_type" => $this->res_type,
+            "res_id" => $this->res_id,
+            "status" => $this->status,
+            "created_at" => $this->created_at,
+            "updated_at" => $this->updated_at,
+        ];
+        $data['channel'] = ChannelApi::getById($this->channel);
+        switch ($this->res_type) {
+            case 'suggestion':
+                $prData = SentPr::where('uid', $this->res_id)->first();
+                if ($prData) {
+                    $link = config('mint.server.dashboard_base_path') . "/article/para/{$prData->book_id}-{$prData->paragraph}";
+                    $link .= "?book={$prData->book_id}&par={$prData->paragraph}&channel={$prData->channel_uid}";
+                    $link .= "&mode=edit&pr=" . $this->res_id;
+                    $data['url'] = $link;
+                    //获取标题
+                    if ($prData->book_id < 1000) {
+                        $path = json_decode(PaliTextApi::getChapterPath($prData->book_id, $prData->paragraph));
+                        if (count($path) > 0) {
+                            $data['title'] = end($path)->title;
+                            $data['book_title'] = $path[0]->title;
+                        } else {
+                            Log::error('no path data', ['pr data' => $prData]);
+                        }
+                        //内容
+                        $orgContent = Sentence::where('book_id', $prData->book_id)
+                            ->where('paragraph', $prData->paragraph)
+                            ->where('word_start', $prData->word_start)
+                            ->where('word_end', $prData->word_end)
+                            ->where('channel_uid', $prData->channel_uid)
+                            ->value('content');
+                        $content = '>' . mb_substr($orgContent, 0, 70, "UTF-8") . "\n\n";
+                        $content .= mb_substr($prData->content, 0, 140, "UTF-8");
+                        $data['content'] = $content;
+                    }
+                }
+                break;
+            case 'discussion':
+                $discussion = Discussion::where('id', $this->res_id)->first();
+                if ($discussion->parent) {
+                    $topic = Discussion::where('id', $discussion->parent)->first();
+                }
+                if ($discussion) {
+                    $link = config('mint.server.dashboard_base_path') . '/discussion/topic/';
+                    if (isset($topic)) {
+                        $link .= "{$topic->id}#{$discussion->id}";
+                    } else {
+                        $link .= "{$discussion->id}";
+                    }
+                    $data['url'] = $link;
+                    //标题
+                    switch ($discussion->res_type) {
+                        case 'sentence':
+                            break;
+                        case 'wbw':
+                            $wbw = Wbw::where('uid', $discussion->res_id)->first();
+                            if ($wbw) {
+                                $data['title'] = $wbw->word;
+                            }
+
+                            break;
+                        default:
+                            break;
+                    }
+                    /*
+                        {
+                            $path = json_decode(PaliTextApi::getChapterPath($prData->book_id,$prData->paragraph));
+                            if(count($path)>0){
+                                $data['title'] = end($path)->title;
+                                $data['book_title'] = $path[0]->title;
+                            }else{
+                                Log::error('no path data',['pr data'=>$prData]);
+                            }
+                            //内容
+                            $orgContent = Sentence::where('book_id',$prData->book_id)
+                                                    ->where('paragraph',$prData->paragraph)
+                                                    ->where('word_start',$prData->word_start)
+                                                    ->where('word_end',$prData->word_end)
+                                                    ->where('channel_uid',$prData->channel_uid)
+                                                    ->value('content');
+                            $content = '>'. mb_substr($orgContent,0,70,"UTF-8")."\n\n";
+                            $content .= mb_substr($prData->content,0,140,"UTF-8");
+                            $data['content'] = $content;
+                        }
+                        */
+                }
+                break;
+            case 'task':
+                $link = config('mint.server.dashboard_base_path') . "/article/task/{$this->res_id}";
+                $data['url'] = $link;
+                break;
+            default:
+                # code...
+                break;
+        }
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/PaliTextResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class PaliTextResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 39 - 0
api-v12/app/Http/Resources/ProjectResource.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\UserApi;
+use App\Http\Api\StudioApi;
+use App\Http\Api\ProjectApi;
+
+class ProjectResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            'id' => $this->uid,
+            'title' => $this->title,
+            'type' => $this->type,
+            'weight' => $this->weight,
+            'description' => $this->description,
+            'executors_id' => json_decode($this->executors_id),
+            'parent_id' => $this->parent_id,
+            'parent' => ProjectApi::getById($this->parent_id),
+            'path' => ProjectApi::getListByIds(json_decode($this->path)),
+            'description' => $this->description,
+            "owner" => StudioApi::getById($this->owner_id),
+            "editor" => UserApi::getByUuid($this->editor_id),
+            'privacy' => $this->privacy,
+            'created_at' => $this->created_at,
+            'updated_at' => $this->updated_at,
+        ];
+        return $data;
+    }
+}

+ 67 - 0
api-v12/app/Http/Resources/RecentResource.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\ChannelApi;
+use App\Models\Sentence;
+use App\Models\Article;
+
+class RecentResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            'id' => $this->id,
+            'type' => $this->type,
+            'article_id' => $this->article_id,
+            'param' => $this->param,
+            'updated_at' => $this->updated_at,
+        ];
+        $title = '';
+        switch ($this->type) {
+            case 'article':
+                $title = Article::where('uid',$this->article_id)->value('title');
+                break;
+            case 'chapter':
+
+
+                if(!empty($this->param)){
+                    $param = json_decode($this->param,true);
+                    if(isset($param['channel'])){
+                        $channelId = explode('_',$param['channel'])[0];
+                    }
+                }
+                $paliChannel = ChannelApi::getSysChannel('_System_Pali_VRI_');
+                if(!isset($channelId)){
+                    $channelId = $paliChannel;
+                }
+                $para = explode('-',$this->article_id);
+                if(count($para)===2){
+                    $title = Sentence::where('book_id',(int)$para[0])
+                                        ->where('paragraph',(int)$para[1])
+                                        ->where('channel_uid',$channelId)
+                                        ->value('content');
+                    if(empty($title)){
+                        $title = Sentence::where('book_id',(int)$para[0])
+                                            ->where('paragraph',(int)$para[1])
+                                            ->where('channel_uid',$paliChannel)
+                                            ->value('content');
+                    }
+                }
+
+                break;
+            default:
+                $title = $this->article_id;
+                break;
+        }
+        $data['title'] = $title;
+        return $data;
+    }
+}

+ 38 - 0
api-v12/app/Http/Resources/RelatedParagraphResource.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\BookTitle;
+use App\Models\PaliText;
+use App\Models\TagMap;
+use App\Models\Tag;
+use Illuminate\Support\Facades\Log;
+
+class RelatedParagraphResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $bookTitle = BookTitle::where('sn',$this["book_id"])->first();
+        $data = [
+            "book"=>$this['book'],
+            "para"=> $this['para'],
+            "book_title_pali"=> $bookTitle->title,
+            'cs6_para'=> $this['cs6_para'],
+        ];
+        $paliTextUuid = PaliText::where('book',$bookTitle->book)->where('paragraph',$bookTitle->paragraph)->value('uid');
+        $tagIds = TagMap::where('anchor_id',$paliTextUuid)->select('tag_id')->get();
+        $data['tags'] = Tag::whereIn('id',$tagIds)->select('id','name','color')->get();
+
+        $data['path'] = json_decode(PaliText::where('book',$this['book'])
+                                        ->where('paragraph',$this['para'][0])
+                                        ->value('path'));
+        return $data;
+    }
+}

+ 71 - 0
api-v12/app/Http/Resources/RelationResource.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\UserApi;
+use App\Http\Api\ChannelApi;
+use App\Models\DhammaTerm;
+
+class RelationResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "id"=>$this->id,
+            "name"=> $this->name,
+            "case"=> $this->case,
+            "from"=> json_decode($this->from),
+            "to"=> json_decode($this->to),
+            "match"=> json_decode($this->match),
+            "category"=> $this->category,
+            "created_at"=> $this->created_at,
+            "updated_at"=> $this->updated_at,
+        ];
+
+
+        if(!$request->has('vocabulary')){
+            //TODO 默认英文
+            $data["editor"] = UserApi::getByUuid($this->editor_id);
+            $lang = $request->get('ui-lang');
+
+            $uiLang = strtolower($request->get('ui-lang','zh-Hans')) ;
+            $term_channel = ChannelApi::getSysChannel("_System_Grammar_Term_{$uiLang}_");
+            if($term_channel){
+                $data['category_channel'] = $term_channel;
+                if(!empty($this->category)){
+                    $term = DhammaTerm::where("word",$this->category)
+                                                ->where('channal',$term_channel)
+                                                ->first();
+                    if($term){
+                        $data['category_term']['channelId'] = $term_channel;
+                        $data['category_term']['word'] = $term->word;
+                        $data['category_term']['id'] = $term->guid;
+                        $data['category_term']['meaning'] = $term->meaning;
+                    }
+                }
+                $data['name_channel'] = $term_channel;
+                $term_name = DhammaTerm::where("word",$this->name)
+                    ->where('channal',$term_channel)
+                    ->first();
+                if($term_name){
+                    $data['name_term']['channelId'] = $term_channel;
+                    $data['name_term']['word'] = $term_name->word;
+                    $data['name_term']['id'] = $term_name->guid;
+                    $data['name_term']['meaning'] = $term_name->meaning;
+                }
+            }
+        }
+        /*
+
+*/
+
+        return $data;
+    }
+}

+ 58 - 0
api-v12/app/Http/Resources/SearchBookResource.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\BookTitle;
+use App\Models\PaliText;
+use App\Models\TagMap;
+
+use Illuminate\Support\Facades\Log;
+
+class SearchBookResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $book = BookTitle::where('sn', $this->pcd_book_id)->first();
+        $data = [
+            'pcdBookId' => $this->pcd_book_id,
+            "count" => $this->co,
+        ];
+        if ($book) {
+            $toc = PaliText::where('book', $book->book)
+                ->where("paragraph", $book->paragraph)
+                ->value('toc');
+            $data["book"] = $book->book;
+            $data["paragraph"] = $book->paragraph;
+            $data["paliTitle"] = $toc;
+            //tags
+            $data["tags"] = $this->getTags($book->book, $book->paragraph);
+        } else {
+            Log::error('book title is null pcd_book_id=' . $this->pcd_book_id);
+            $data["book"] = 0;
+            $data["paragraph"] = 0;
+            $data["paliTitle"] = '';
+        }
+
+        return $data;
+    }
+
+    private function getTags(string $book, string $para)
+    {
+        $uid = PaliText::where('book', $book)->where('paragraph', $para)->first()->uid;
+        $tagsName = TagMap::where('table_name', 'pali_texts')
+            ->where('anchor_id', $uid)
+            ->join('tags', 'tag_maps.tag_id', '=', 'tags.id')
+            ->select('tags.name')
+            ->get();
+
+        Log::info('tag name', ['data' => $tagsName]);
+        return $tagsName;
+    }
+}

+ 57 - 0
api-v12/app/Http/Resources/SearchPaliWbwResource.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\PaliText;
+
+class SearchPaliWbwResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "book"=>$this->book,
+            "paragraph"=> $this->paragraph,
+        ];
+        if(isset($this->rank)){
+            $data["rank"] = $this->rank;
+        }
+        $paliText = PaliText::where('book',$this->book)
+                    ->where('paragraph',$this->paragraph)
+                    ->first();
+        if($paliText){
+            $data['path'] = json_decode($paliText->path);
+            if($paliText->level<100){
+                $data["paliTitle"] = $paliText->toc;
+            }else{
+                $data["paliTitle"] = PaliText::where('book',$this->book)
+                                            ->where('paragraph',$paliText->parent)
+                                            ->value('toc');
+            }
+            $keyWords = explode(',',$request->get('key'));
+            $keyWordsUpper=$keyWords;
+            foreach ($keyWords as $key => $word) {
+                if(mb_substr($word,-3,null,"UTF-8")==='nti'){
+                    $keyWordsUpper[] = mb_substr($word,0,mb_strlen($word,"UTF-8")-3,"UTF-8");
+                }else if(mb_substr($word,-3,null,"UTF-8")==='ti'){
+                    $keyWordsUpper[] = mb_substr($word,0,mb_strlen($word,"UTF-8")-2,"UTF-8");
+                }
+            }
+            foreach ($keyWords as $key => $word) {
+                $keyWordsUpper[] = mb_strtoupper(mb_substr($word,0,1,"UTF-8"),"UTF-8").mb_substr($word,1,null,"UTF-8");
+            }
+            $keyReplace = array();
+            foreach ($keyWordsUpper as $key => $word) {
+                $keyReplace[] = "<span class='hl'>{$word}</span>";
+            }
+            $data["highlight"] = str_replace($keyWordsUpper,$keyReplace,$paliText->html);
+        }
+        return $data;
+    }
+}

+ 68 - 0
api-v12/app/Http/Resources/SearchResource.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\PaliText;
+use App\Models\Sentence;
+use App\Http\Api\ChannelApi;
+use Illuminate\Support\Facades\Cache;
+use App\Tools\RedisClusters;
+
+
+class SearchResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "book"=>$this->book,
+            "paragraph"=> $this->paragraph,
+        ];
+        if(isset($this->rank)){
+            $data["rank"] = $this->rank;
+        }
+        $paliText = PaliText::where('book',$this->book)
+                            ->where('paragraph',$this->paragraph)
+                            ->first();
+        if(isset($this->highlight)){
+            $data["highlight"] = $this->highlight;
+        }else if(isset($this->content)){
+            $data["content"] = $this->content;
+        }else{
+            $channelId = RedisClusters::remember('_System_Pali_VRI_',config('mint.cache.expire'),function(){
+                return ChannelApi::getSysChannel('_System_Pali_VRI_');
+            });
+
+            $paraContent = Sentence::where('book_id',$this->book)
+                ->where('paragraph',$this->paragraph)
+                ->where('channel_uid',$channelId)
+                ->orderBy('word_start')
+                ->select('content')
+                ->get();
+            $html = '';
+            foreach ($paraContent as $key => $value) {
+                $html .= $value->content;
+            }
+            $data["content"] = $html;
+        }
+
+        if($paliText){
+            $data['path'] = json_decode($paliText->path);
+            if($paliText->level<100){
+                $data["paliTitle"] = $paliText->toc;
+            }else{
+                $data["paliTitle"] = PaliText::where('book',$this->book)
+                                            ->where('paragraph',$paliText->parent)
+                                            ->value('toc');
+            }
+
+        }
+        return $data;
+    }
+}

+ 24 - 0
api-v12/app/Http/Resources/SearchTitleIndexResource.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class SearchTitleIndexResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            'word'=> $this->text,
+            'count'=> 0,
+            'bold'=> 0,
+        ];
+        return $data;
+    }
+}

+ 31 - 0
api-v12/app/Http/Resources/SearchTitleResource.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\PaliText;
+
+class SearchTitleResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "book"=>$this->book,
+            "paragraph"=> $this->paragraph,
+            'content'=>$this->text,
+            'path' => json_decode($this->path),
+            'paliTitle' => $this->toc,
+        ];
+        $data["content"] = PaliText::where('book',$this->book)
+                                            ->where('paragraph',$this->paragraph+1)
+                                            ->value('html');
+        $data["content_type"] = 'html';
+        return $data;
+    }
+}

+ 42 - 0
api-v12/app/Http/Resources/SentHistoryResource.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\UserApi;
+use App\Http\Api\ChannelApi;
+use App\Http\Api\StudioApi;
+
+class SentHistoryResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            'id' => $this->id,
+            'sent_uid' => $this->sent_uid,
+            "editor" => UserApi::getByUuId($this->user_uid),
+            'content' => $this->content,
+            'landmark' => $this->landmark,
+            'pr_from' => $this->pr_from,
+            'created_at' => $this->created_at
+        ];
+        if($this->fork_from){
+            $fork_from = ChannelApi::getById($this->fork_from);
+            if($fork_from){
+                $data['fork_from'] = $fork_from;
+                $data['fork_studio'] = StudioApi::getById($fork_from['studio_id']);
+
+            }
+        }
+        if($this->accepter_uid){
+            $data['accepter'] = UserApi::getByUuId($this->accepter_uid);
+        }
+        return $data;
+    }
+}

+ 45 - 0
api-v12/app/Http/Resources/SentPrResource.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\MdRender;
+use App\Http\Api\UserApi;
+use App\Http\Api\AuthApi;
+use App\Http\Api\ChannelApi;
+
+class SentPrResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        //获取用户信息
+        $user = AuthApi::current($request);
+        $role = 'reader';
+        if($user && $user["user_uid"] === $this->editor_uid ){
+            $role = 'owner';
+        }
+        $channel = ChannelApi::getById($this->channel_uid);
+        $mode = $request->get("mode",'read');
+        return [
+            "id"=>$this->id,
+            "uid"=>$this->uid,
+            "book"=> $this->book_id,
+            "paragraph"=> $this->paragraph,
+            "word_start"=> $this->word_start,
+            "word_end"=> $this->word_end,
+            "editor"=> UserApi::getByUuid($this->editor_uid),
+            "channel"=> $channel,
+            "content"=>$this->content,
+            "html"=> MdRender::render($this->content,[$this->channel_uid],null,$mode,$channel['type']),
+            "role"=>$role,
+            "created_at"=> $this->created_at,
+            "updated_at"=> $this->updated_at,
+        ];
+    }
+}

+ 87 - 0
api-v12/app/Http/Resources/SentResource.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace App\Http\Resources;
+
+use App\Http\Api\MdRender;
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\StudioApi;
+use App\Http\Api\UserApi;
+use App\Http\Api\ChannelApi;
+use App\Http\Api\SuggestionApi;
+use Illuminate\Support\Str;
+use Illuminate\Support\Facades\Log;
+
+class SentResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $channel = ChannelApi::getById($this->channel_uid);
+        if(!$channel){
+            Log::error('channel left',['data'=>$this->channel_uid,'uid'=>$this->uid]);
+        }
+        if($request->get('mode','read')==="read"){
+            $mode = 'read';
+        }else{
+            $mode = 'edit';
+        }
+        $data = [
+                "id" => $this->uid,
+                "content"=>$this->content,
+                "content_type"=>$this->content_type,
+                "html"=> "",
+                "book"=> $this->book_id,
+                "paragraph"=> $this->paragraph,
+                "word_start"=> $this->word_start,
+                "word_end"=> $this->word_end,
+                "editor"=> UserApi::getByUuid($this->editor_uid),
+                'fork_at' => $this->fork_at,
+                "updated_at"=> $this->updated_at,
+            ];
+
+        if($channel){
+            $data['channel'] = $channel;
+            $data['studio'] = StudioApi::getById($channel["studio_id"]);
+        }
+        if($request->has('channels')){
+            $channels = explode(',',$request->get('channels'));
+        }else{
+            $channels = [$this->channel_uid];
+        }
+        //TODO 找出channel id = '' 的原因
+        $mChannels=array();
+        foreach ($channels as $key => $value) {
+            if(Str::isUuid($value)){
+                $mChannels[] = $value;
+            }
+        }
+        if($request->get('html',true)){
+            $data['html'] = MdRender::render($this->content,
+                                             $mChannels,
+                                             null,
+                                             $mode,
+                                             $channel['type'],
+                                             $this->content_type,
+                                             $request->get('format','react')
+                                            );
+        }
+        if($request->get('mode') === "edit" || $request->get('mode') === "wbw"){
+            $data['suggestionCount'] = SuggestionApi::getCountBySent($this->book_id,
+                                                                   $this->paragraph,
+                                                                   $this->word_start,
+                                                                   $this->word_end,
+                                                                   $this->channel_uid
+                                                                );
+        }
+        if(isset($this->acceptor_uid) && !empty($this->acceptor_uid)){
+            $data["acceptor"]=UserApi::getByUuid($this->acceptor_uid);
+            $data["pr_edit_at"]=$this->pr_edit_at;
+        }
+        return $data;
+    }
+}

+ 34 - 0
api-v12/app/Http/Resources/SentSimResource.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\PaliSentence;
+use App\Models\PaliText;
+use App\Http\Api\UserApi;
+use App\Http\Api\ChannelApi;
+use App\Http\Controllers\CorpusController;
+use App\Http\Api\AuthApi;
+
+class SentSimResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        //获取实际句子信息
+        $sent = PaliSentence::find($this->sent2);
+        $channels = explode(',',$request->get('channels'));
+        $mode = explode(',',$request->get('mode','read'));
+        $sentId = $sent->book.'-'.$sent->paragraph.'-'.$sent->word_begin.'-'.$sent->word_end;
+        $Sent = new CorpusController();
+        $tpl =
+        $data['sent'] = $Sent->getSentTpl($sentId,$channels,$mode);
+        $data['sim'] = $this->sim;
+        return $data;
+    }
+}

+ 43 - 0
api-v12/app/Http/Resources/SentenceAttachmentResource.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Log;
+use App\Models\Attachment;
+use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Facades\App;
+
+class SentenceAttachmentResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $url = config('app.url') . '/api/v2/attachment/' . $this->attachment_id;
+        Log::info($url);
+        //$response = Http::get($url);
+
+
+        $data = [
+            'uid' => $this->uid,
+            'sentence_id' => $this->sentence_id,
+            'attachment_id' => $this->attachment_id,
+            'attachment' => [],
+            'editor_id' => $this->editor_id,
+        ];
+        $res = Attachment::find($this->attachment_id);
+        $filename = $res->bucket . '/' . $res->name;
+        if (App::environment('local')) {
+            $data['attachment']['url'] = Storage::url($filename);
+        } else {
+            $data['attachment']['url'] = Storage::temporaryUrl($filename, now()->addDays(2));
+        }
+        return $data;
+    }
+}

+ 92 - 0
api-v12/app/Http/Resources/ShareResource.php

@@ -0,0 +1,92 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\Channel;
+use App\Models\Article;
+use App\Models\Collection;
+use App\Models\Project;
+use App\Http\Api\StudioApi;
+use App\Http\Api\GroupApi;
+use App\Http\Api\UserApi;
+
+class ShareResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        //获取资源信息
+        $res_name = "";
+        $owner = "";
+        switch ($this->res_type) {
+            case 1:
+                # PCS 文档
+                break;
+            case 2:
+                # Channel 版本
+                $res = Channel::where('uid', $this->res_id)->first();
+                if ($res) {
+                    $res_name = $res->name;
+                    $owner = StudioApi::getById($res->owner_uid);
+                }
+                break;
+            case 3:
+                # Article 文章
+                $res = Article::where('uid', $this->res_id)->first();
+                if ($res) {
+                    $res_name = $res->title;
+                    $owner = StudioApi::getById($res->owner);
+                }
+                break;
+            case 4:
+                # Collection 文集
+                $res = Collection::where('uid', $this->res_id)->first();
+                if ($res) {
+                    $res_name = $res->title;
+                    $owner = StudioApi::getById($res->owner);
+                }
+                break;
+            case 5:
+                # 版本片段 不支持
+                break;
+            case 6: //workflow
+                $res = Project::where('uid', $this->res_id)->first();
+                if ($res) {
+                    $res_name = $res->title;
+                    $owner = StudioApi::getById($res->owner_id);
+                }
+                break;
+            default:
+                # code...
+                break;
+        }
+        $data = [
+            "id" => $this->id,
+            "res_id" => $this->res_id,
+            "res_type" => $this->res_type,
+            "collaborator_type" => $this->cooperator_type,
+            "power" => $this->power,
+            'res_name' => $res_name,
+            'owner' => $owner,
+            "created_at" => $this->created_at,
+            "updated_at" => $this->updated_at,
+        ];
+        switch ($this->cooperator_type) {
+            case 0:
+                # user
+                $data['user'] = UserApi::getByUuid($this->cooperator_id);
+                break;
+            case 1:
+                # code...
+                $data['group'] = GroupApi::getById($this->cooperator_id);
+                break;
+        }
+        return $data;
+    }
+}

+ 53 - 0
api-v12/app/Http/Resources/TagMapResource.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\TagMap;
+use App\Models\Wbw;
+use App\Http\Api\StudioApi;
+use App\Http\Api\UserApi;
+
+class TagMapResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            'id' => $this->id,
+            'table_name' => $this->table_name,
+            'anchor_id' => $this->anchor_id,
+            'tag_id' => $this->tag_id,
+            'name' => $this->name,
+            'color' => $this->color,
+            'description' => $this->description,
+            "editor"=> UserApi::getByUuid($this->editor_uid),
+            "owner" => StudioApi::getById($this->owner_uid),
+            'created_at' => $this->created_at,
+            'updated_at' => $this->updated_at,
+        ];
+
+        switch ($this->table_name) {
+            case 'sentence':
+                # code...
+                break;
+            case 'wbw-sentence':
+                $data['title'] = '';
+                break;
+            case 'wbw':
+                $wbw = Wbw::where('uid',$this->anchor_id)->first();
+                $data['title'] = $wbw->word;
+                break;
+            default:
+                break;
+        }
+        $tagsId = TagMap::where('anchor_id',$this->anchor_id)->select('tag_id');
+        $data['tags'] = $tagsId;
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/TagResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class TagResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 80 - 0
api-v12/app/Http/Resources/TaskResource.php

@@ -0,0 +1,80 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\UserApi;
+use App\Http\Api\StudioApi;
+use App\Http\Api\TaskApi;
+use App\Http\Api\ProjectApi;
+use App\Http\Api\MdRender;
+use App\Models\TaskAssignee;
+
+use Illuminate\Support\Str;
+
+class TaskResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+
+        $htmlRender = new MdRender([
+            'mode' => 'read',
+            'format' => 'react',
+            'footnote' => true,
+            'origin' => $request->get('origin', true),
+            'paragraph' => $request->get('paragraph', false),
+        ]);
+        $data = [
+            'id' => $this->id,
+            'title' => $this->title,
+            'description' => $this->description,
+            'type' => $this->type,
+            'category' => $this->category,
+            'progress' => $this->progress,
+            'parent_id' => $this->parent_id,
+            'parent' => TaskApi::getById($this->parent_id),
+            'roles' => $this->roles,
+            'executor_id' => $this->executor_id,
+            'executor_relation_task_id' => $this->executor_relation_task_id,
+            'executor_relation_task' => TaskApi::getById($this->executor_relation_task_id),
+            'pre_task' => TaskApi::getPreTasks($this->id),
+            'next_task' => TaskApi::getNextTasks($this->id),
+            'is_milestone' => $this->is_milestone,
+            'project_id' => $this->project_id,
+            'project' => ProjectApi::getById($this->project_id),
+            'owner_id' => $this->owner_id,
+            "owner" => StudioApi::getById($this->owner_id),
+            'editor_id' => $this->editor_id,
+            "editor" => UserApi::getByUuid($this->editor_id),
+            'order' => $this->order,
+            'status' => $this->status,
+            'created_at' => $this->created_at,
+            'updated_at' => $this->updated_at,
+            'started_at' => $this->started_at,
+            'finished_at' => $this->finished_at,
+        ];
+        $assignees = TaskAssignee::where('task_id', $this->id)->select('assignee_id')->get();
+        if (count($assignees) > 0) {
+            $assignees_id = [];
+            foreach ($assignees as $key => $value) {
+                $assignees_id[] = $value->assignee_id;
+            }
+            $data['assignees_id'] = $assignees_id;
+            $data['assignees'] = UserApi::getListByUuid($assignees_id);
+        }
+        if (!empty($this->description)) {
+            $data["html"] = $htmlRender->convert($this->description, []);
+        }
+
+        if (Str::isUuid($this->executor_id)) {
+            $data["executor"] = UserApi::getByUuid($this->executor_id);
+        }
+        return $data;
+    }
+}

+ 132 - 0
api-v12/app/Http/Resources/TermResource.php

@@ -0,0 +1,132 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use Illuminate\Support\Str;
+
+use App\Http\Api\ChannelApi;
+use App\Http\Api\StudioApi;
+use App\Http\Api\UserApi;
+use App\Http\Api\MdRender;
+use App\Http\Api\ShareApi;
+use App\Http\Api\AuthApi;
+use App\Models\UserOperationDaily;
+use App\Models\DhammaTerm;
+
+class TermResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "id" => $this->id,
+            "guid" => $this->guid,
+            "word" => $this->word,
+            "word_en" => $this->word_en,
+            "meaning" => $this->meaning,
+            "other_meaning" => $this->other_meaning,
+            "tag" => $this->tag,
+            "note" => $this->note,
+            "language" => $this->language,
+            "channal" => $this->channal,
+            "studio" => StudioApi::getById($this->owner),
+            "editor" => UserApi::getById($this->editor_id),
+            "created_at" => $this->created_at,
+            "updated_at" => $this->updated_at,
+        ];
+
+
+        if ($request->has('channel') && !empty($request->get('channel'))) {
+            $channels = explode('_', $request->get('channel'));
+        } else {
+            if (!empty($this->channal) && Str::isUuid($this->channal)) {
+                $channelId = $this->channal;
+                $data["channel"] = ChannelApi::getById($this->channal);
+            } else {
+                $channelId = ChannelApi::getSysChannel('_community_translation_' . $this->language . '_');
+                if (empty($channelId)) {
+                    $channelId = ChannelApi::getSysChannel('_community_translation_zh-hans_');
+                }
+            }
+            if (!empty($channelId)) {
+                $channels = [$channelId];
+            } else {
+                $channels = [];
+            }
+        }
+
+
+        if (!empty($this->note)) {
+            $mdRender = new MdRender(
+                [
+                    'mode' => $request->get('mode', 'read'),
+                    'format' => 'react',
+                    'studioId' => $this->owner,
+                ]
+            );
+            $data["html"]  = $mdRender->convert($this->note, $channels, null);
+            $summaryContent = $this->note;
+        } else if ($request->has('community_summary')) {
+            $lang = strtolower($this->language);
+            if ($lang === 'zh') {
+                $lang = 'zh-hans';
+            }
+            $community_channel = ChannelApi::getSysChannel("_community_term_{$lang}_");
+            if (empty($community_channel)) {
+                $community_channel = ChannelApi::getSysChannel('_community_term_zh-hans_');
+            }
+            if (Str::isUuid($community_channel)) {
+                //查找社区解释
+                $community_note = DhammaTerm::where("word", $this->word)
+                    ->where('channal', $community_channel)
+                    ->value('note');
+                if (!empty($community_note)) {
+                    $summaryContent = $community_note;
+                    $data["summary_is_community"] = true;
+                }
+            }
+        }
+        if (isset($summaryContent)) {
+            $mdRender = new MdRender(
+                [
+                    'mode' => $request->get('mode', 'read'),
+                    'format' => 'text',
+                    'studioId' => $this->owner,
+                ]
+            );
+            $data["summary"]  = $mdRender->convert($summaryContent, $channels, null);
+        }
+
+        $user = AuthApi::current($request);
+        if (!$user) {
+            $data["role"] = 'reader';
+        } else {
+            if ($this->owner === $user['user_uid']) {
+                $data["role"] = 'owner';
+            } else if (!empty($this->channal)) {
+                $power = ShareApi::getResPower($user['user_uid'], $this->channal);
+                if ($power === 20) {
+                    $data["role"] = 'editor';
+                } else if ($power === 10) {
+                    $data["role"] = 'reader';
+                } else {
+                    $data["role"] = 'unknown';
+                }
+            }
+        }
+        if ($request->has('exp')) {
+            //毫秒计算的经验值
+            $exp = UserOperationDaily::where('user_id', $this->editor_id)
+                ->where('date_int', '<=', date_timestamp_get(date_create($this->updated_at)) * 1000)
+                ->sum('duration');
+            $data['exp'] = (int)($exp / 1000);
+        }
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/TermVocabularyResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class TermVocabularyResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 62 - 0
api-v12/app/Http/Resources/TocResource.php

@@ -0,0 +1,62 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\ProgressChapter;
+
+class TocResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "book"=>$this->book,
+            "paragraph"=> $this->paragraph,
+            "pali_title"=> $this->toc,
+            "level"=>$this->level
+        ];
+
+        $title= ProgressChapter::where('book',$this->book)
+                                        ->where('para',$this->paragraph)
+                                        ->where('lang','zh')
+                                        ->whereNotNull('title')
+                                        ->value('title');
+        if(!empty($title)){
+            $data['title'] = $title;
+        }
+        if($request->has('channels')){
+            if(strpos($request->get('channels'),',') ===FALSE){
+                $channels = explode('_',$request->get('channels'));
+            }else{
+                $channels = explode(',',$request->get('channels'));
+            }
+            $title = ProgressChapter::where('book',$this->book)
+                                ->where('para',$this->paragraph)
+                                ->where('channel_id',$channels[0])
+                                ->whereNotNull('title')
+                                ->value('title');
+            if(!empty($title)){
+                $data['title'] = $title;
+            }
+            //查询完成度
+            foreach ($channels as $key => $channel) {
+                $progress = ProgressChapter::where('book',$this->book)
+                                ->where('para',$this->paragraph)
+                                ->where('channel_id',$channel)
+                                ->value('progress');
+                if($progress){
+                    $data['progress'][] = $progress;
+                }else{
+                    $data['progress'][] = 0;
+                }
+            }
+        }
+        return $data;
+    }
+}

+ 44 - 0
api-v12/app/Http/Resources/TransferResource.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\StudioApi;
+use App\Http\Api\UserApi;
+use App\Http\Api\ChannelApi;
+
+class TransferResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "id" => $this->id,
+            "origin_owner"=>StudioApi::getById($this->origin_owner),
+            "res_type"=>$this->res_type,
+            "res_id"=> $this->res_id,
+            "transferor"=> UserApi::getByUuid($this->transferor_id),
+            "new_owner"=> StudioApi::getById($this->new_owner),
+            "status"=> $this->status,
+            "updated_at"=> $this->updated_at,
+            "created_at"=> $this->created_at,
+        ];
+        if(!empty($this->editor_id)){
+            $data['editor'] = UserApi::getByUuid($this->editor_id);
+        }
+        switch ($this->res_type) {
+            case 'channel':
+                $data['channel'] = ChannelApi::getById($this->res_id);
+                break;
+            default:
+                # code...
+                break;
+        }
+        return $data;
+    }
+}

+ 53 - 0
api-v12/app/Http/Resources/UserDictResource.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use App\Http\Api\UserApi;
+use App\Models\UserOperationDaily;
+use App\Models\DictInfo;
+use App\Http\Api\MdRender;
+
+class UserDictResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+		 'id'=>$this->id,
+         'word'=>$this->word,
+         'type'=>$this->type,
+         'grammar'=>$this->grammar,
+         'mean'=>$this->mean,
+         'parent'=>$this->parent,
+         'note'=>$this->note,
+         'factors'=>$this->factors,
+         'source'=>$this->source,
+         'status'=>$this->status,
+         'confidence'=>$this->confidence,
+         'updated_at'=>$this->updated_at,
+         'creator_id'=>$this->creator_id,
+        ];
+        if(!empty($this->note)){
+            $mdRender = new MdRender(['format'=>'react','lang'=>'zh-Hans']);
+            $data['note'] = $mdRender->convert($this->note);
+        }
+        if($request->get('view')==='community'){
+            $data['editor'] = UserApi::getById($this->creator_id);
+            //毫秒计算的经验值
+            $exp = UserOperationDaily::where('user_id',$this->creator_id)
+                                                ->where('date_int','<=',date_timestamp_get(date_create($this->updated_at))*1000)
+                                                ->sum('duration');
+            $data['exp'] = (int)($exp/1000);
+        }
+        if($request->get('view')==='all'){
+            $data['dict'] = DictInfo::where('id',$this->dict_id)->select(['id','name','shortname'])->first();
+        }
+        return $data;
+    }
+}

+ 39 - 0
api-v12/app/Http/Resources/UserResource.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Facades\App;
+
+class UserResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "id" => $this->userid,
+            "userName" => $this->username,
+            "nickName" => $this->nickname,
+            "email" => $this->email,
+            "role" => json_decode($this->role),
+            "created_at" => $this->created_at,
+            "updated_at" => $this->updated_at,
+        ];
+        if($this->avatar){
+            $data['avatarName'] = $this->avatar;
+            $img = str_replace('.jpg','_s.jpg',$this->avatar);
+            if (App::environment('local')) {
+                $data['avatar'] = Storage::url($img);
+            }else{
+                $data['avatar'] = Storage::temporaryUrl($img, now()->addDays(6));
+            }
+        }
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/ViewResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class ViewResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 28 - 0
api-v12/app/Http/Resources/VocabularyResource.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+use Illuminate\Support\Facades\Cache;
+use App\Tools\RedisClusters;
+use App\Http\Controllers\DictMeaningController;
+
+class VocabularyResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $dictMeaning = new DictMeaningController();
+        return [
+            "word"=>$this['word'],
+            "count"=> $this['count'],
+            "strlen"=> $this['strlen'],
+            "meaning"=> $dictMeaning->get($this['word'],$request->get("lang","zh-Hans")),
+        ];
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/WbwResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class WbwResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/WbwTemplateResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class WbwTemplateResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}

+ 32 - 0
api-v12/app/Http/Resources/WebHookResource.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class WebHookResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        $data = [
+            "id"=>$this->id,
+            "res_type"=> $this->res_type,
+            "res_id"=> $this->res_id,
+            "url"=> $this->url,
+            "receiver"=> $this->receiver,
+            "event"=> json_decode($this->event),
+            "status"=> $this->status,
+            "fail"=> $this->fail,
+            "success"=> $this->success,
+            "created_at"=> $this->created_at,
+            "updated_at"=> $this->updated_at,
+        ];
+        return $data;
+    }
+}

+ 19 - 0
api-v12/app/Http/Resources/WordIndexResource.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class WordIndexResource extends JsonResource
+{
+    /**
+     * Transform the resource into an array.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
+     */
+    public function toArray($request)
+    {
+        return parent::toArray($request);
+    }
+}