فهرست منبع

$request->get => input

visuddhinanda 5 روز پیش
والد
کامیت
46d07ffc49

+ 13 - 13
api-v12/app/Http/Resources/ArticleMapResource.php

@@ -23,7 +23,7 @@ class ArticleMapResource extends JsonResource
             "article_id" => $this->article_id,
             "article_id" => $this->article_id,
             "level" => $this->level,
             "level" => $this->level,
             "title" => $this->title,
             "title" => $this->title,
-            "editor"=> UserApi::getById($this->editor_id),
+            "editor" => UserApi::getById($this->editor_id),
             "children" => $this->children,
             "children" => $this->children,
             'status' => $this->status,
             'status' => $this->status,
             "deleted_at" => $this->deleted_at,
             "deleted_at" => $this->deleted_at,
@@ -31,21 +31,21 @@ class ArticleMapResource extends JsonResource
             "updated_at" => $this->updated_at,
             "updated_at" => $this->updated_at,
         ];
         ];
         $channels = [];
         $channels = [];
-        if($request->has('channel')){
-            $channels = explode('_',$request->get('channel')) ;
-        }else{
-            $defaultChannel = Collection::where('uid',$this->collect_id)->value('default_channel');
-            if($defaultChannel){
+        if ($request->has('channel')) {
+            $channels = explode('_', $request->input('channel'));
+        } else {
+            $defaultChannel = Collection::where('uid', $this->collect_id)->value('default_channel');
+            if ($defaultChannel) {
                 $channels[] = $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;
+        $mdRender = new MdRender(['format' => 'simple']);
+        $data['title_text'] = $mdRender->convert($this->title, $channels);
+        if ($request->input('view') === 'article') {
+            $collection = Collection::where('uid', $this->collect_id)->first();
+            if ($collection) {
+                $data['collection']['id'] = $collection->uid;
+                $data['collection']['title'] = $collection->title;
             }
             }
         }
         }
         return $data;
         return $data;

+ 93 - 79
api-v12/app/Http/Resources/ArticleResource.php

@@ -36,8 +36,8 @@ class ArticleResource extends JsonResource
             "title" => $this->title,
             "title" => $this->title,
             "subtitle" => $this->subtitle,
             "subtitle" => $this->subtitle,
             "summary" => $this->summary,
             "summary" => $this->summary,
-            "studio"=> StudioApi::getById($this->owner),
-            "editor"=> UserApi::getById($this->editor_id),
+            "studio" => StudioApi::getById($this->owner),
+            "editor" => UserApi::getById($this->editor_id),
             "status" => $this->status,
             "status" => $this->status,
             "lang" => $this->lang,
             "lang" => $this->lang,
             "parent_uid" => $this->parent,
             "parent_uid" => $this->parent,
@@ -46,78 +46,84 @@ class ArticleResource extends JsonResource
         ];
         ];
 
 
         $user = AuthApi::current($request);
         $user = AuthApi::current($request);
-        if($user){
-            $canEdit = ArticleController::userCanEdit($user['user_uid'],$this);
-            if($canEdit){
+        if ($user) {
+            $canEdit = ArticleController::userCanEdit($user['user_uid'], $this);
+            if ($canEdit) {
                 $data['role'] = 'editor';
                 $data['role'] = 'editor';
             }
             }
         }
         }
 
 
         //查询该文章在哪些文集中出现
         //查询该文章在哪些文集中出现
-        $collectionCount = ArticleCollection::where('article_id',$this->uid)->count();
-        if($collectionCount>0){
+        $collectionCount = ArticleCollection::where('article_id', $this->uid)->count();
+        if ($collectionCount > 0) {
             $data['anthology_count'] = $collectionCount;
             $data['anthology_count'] = $collectionCount;
-            $collection = ArticleCollection::where('article_id',$this->uid)->first();
+            $collection = ArticleCollection::where('article_id', $this->uid)->first();
             $data['anthology_first'] = Collection::find($collection->collect_id);
             $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();
+        if ($request->has('anthology') && Str::isUuid($request->input('anthology'))) {
+            $anthology = Collection::where('uid', $request->input('anthology'))->first();
         }
         }
         //渲染简化版标题
         //渲染简化版标题
         $channels = [];
         $channels = [];
-        if($request->has('channel')){
+        if ($request->has('channel')) {
             //有channel
             //有channel
-            $channels = explode('_',$request->get('channel')) ;
-        }else if(isset($anthology) && $anthology && !empty($anthology->default_channel)){
+            $channels = explode('_', $request->input('channel'));
+        } else if (isset($anthology) && $anthology && !empty($anthology->default_channel)) {
             //没有channel,使用文集channel
             //没有channel,使用文集channel
             $channels[] = $anthology->default_channel;
             $channels[] = $anthology->default_channel;
         }
         }
-        $mdRender = new MdRender(['format'=>'simple']);
+        $mdRender = new MdRender(['format' => 'simple']);
 
 
         //path
         //path
-        if($request->has('anthology') && Str::isUuid($request->get('anthology'))){
+        if ($request->has('anthology') && Str::isUuid($request->input('anthology'))) {
             $data['path'] = array();
             $data['path'] = array();
-            if(isset($anthology) && $anthology){
-                $data['path'][] = ['key'=>$anthology->uid,
-                            'title'=>$anthology->title,
-                            'level'=>0];
+            if (isset($anthology) && $anthology) {
+                $data['path'][] = [
+                    'key' => $anthology->uid,
+                    'title' => $anthology->title,
+                    'level' => 0
+                ];
             }
             }
 
 
             $currLevel = -1;
             $currLevel = -1;
-            $aList = ArticleCollection::where('collect_id',$request->get('anthology'))
-                                                ->orderBy('id','desc')
-                                                ->select(['article_id','title','level'])->get();
+            $aList = ArticleCollection::where('collect_id', $request->input('anthology'))
+                ->orderBy('id', 'desc')
+                ->select(['article_id', 'title', 'level'])->get();
             $path = array();
             $path = array();
             foreach ($aList as $article) {
             foreach ($aList as $article) {
-                if($article->article_id === $this->uid ||
-                ($currLevel >= 0 && $article->level < $currLevel)){
+                if (
+                    $article->article_id === $this->uid ||
+                    ($currLevel >= 0 && $article->level < $currLevel)
+                ) {
                     $currLevel = $article->level;
                     $currLevel = $article->level;
-                    $path[] = ['key'=>$article->article_id,
-                                'title'=>$mdRender->convert($article->title,$channels),
-                                'level'=>$article->level];
+                    $path[] = [
+                        'key' => $article->article_id,
+                        'title' => $mdRender->convert($article->title, $channels),
+                        'level' => $article->level
+                    ];
                 }
                 }
             }
             }
-            for ($i=count($path)-1; $i >=0 ; $i--) {
+            for ($i = count($path) - 1; $i >= 0; $i--) {
                 $data['path'][] = $path[$i];
                 $data['path'][] = $path[$i];
             }
             }
 
 
             //下级目录
             //下级目录
             $level = -1;
             $level = -1;
             $subToc = array();
             $subToc = array();
-            for ($i=count($aList)-1; $i >=0 ; $i--) {
+            for ($i = count($aList) - 1; $i >= 0; $i--) {
                 $article = $aList[$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
+                if ($level >= 0) {
+                    if ($article->level > $level) {
+                        $subToc[] = [
+                            "key" => $article->article_id,
+                            "title" => $mdRender->convert($article->title, $channels),
+                            "level" => $article->level
                         ];
                         ];
-                    }else{
+                    } else {
                         break;
                         break;
                     }
                     }
                 }
                 }
-                if($article->article_id === $this->uid){
+                if ($article->article_id === $this->uid) {
                     $level = $article->level;
                     $level = $article->level;
                 }
                 }
             }
             }
@@ -125,32 +131,34 @@ class ArticleResource extends JsonResource
         }
         }
 
 
 
 
-        $data['title_text'] = $mdRender->convert($this->title,$channels);
+        $data['title_text'] = $mdRender->convert($this->title, $channels);
 
 
         //render html
         //render html
         $channels = array();
         $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){
+        if (isset($this->content) && !empty($this->content)) {
+            if ($request->has('channel')) {
+                $channels = explode('_', $request->input('channel'));
+            } else if ($request->has('anthology')) {
+                $defaultChannel = Collection::where('uid', $request->input('anthology'))
+                    ->value('default_channel');
+                if ($defaultChannel) {
                     $channels[] = $defaultChannel;
                     $channels[] = $defaultChannel;
                 }
                 }
             }
             }
-            if(count($channels) === 0){
+            if (count($channels) === 0) {
                 //查找用户默认channel
                 //查找用户默认channel
-                $studioChannel = Channel::where('owner_uid',$this->owner)
-                                        ->where('type','translation')
-                                        ->get();
-                if($studioChannel){
+                $studioChannel = Channel::where('owner_uid', $this->owner)
+                    ->where('type', 'translation')
+                    ->get();
+                if ($studioChannel) {
                     $channelId = $studioChannel[0]->uid;
                     $channelId = $studioChannel[0]->uid;
                     $channels = [$channelId];
                     $channels = [$channelId];
-                }else{
-                    $channelId = ChannelApi::getSysChannel('_community_translation_'.strtolower($this->lang).'_',
-                                                        '_community_translation_en_');
-                    if($channelId){
+                } else {
+                    $channelId = ChannelApi::getSysChannel(
+                        '_community_translation_' . strtolower($this->lang) . '_',
+                        '_community_translation_en_'
+                    );
+                    if ($channelId) {
                         $channels = [$channelId];
                         $channels = [$channelId];
                     }
                     }
                 }
                 }
@@ -158,57 +166,63 @@ class ArticleResource extends JsonResource
             $data["content"] = $this->content;
             $data["content"] = $this->content;
             $data["content_type"] = $this->content_type;
             $data["content_type"] = $this->content_type;
             $query_id = null;
             $query_id = null;
-            if($request->has('course')){
-                if($request->has('exercise')){
-                    $query_id = $request->get('exercise');
-                    if($request->has('user')){
+            if ($request->has('course')) {
+                if ($request->has('exercise')) {
+                    $query_id = $request->input('exercise');
+                    if ($request->has('user')) {
                         /**
                         /**
                          * 显示指定用户作业
                          * 显示指定用户作业
                          * 查询用户在课程中的channel
                          * 查询用户在课程中的channel
                          */
                          */
-                        $userId = UserApi::getIdByName($request->get('user'));
+                        $userId = UserApi::getIdByName($request->input('user'));
 
 
-                        $userInCourse = CourseMember::where('course_id',$request->get('course'))
-                                    ->where('user_id',$userId)
-                                    ->first();
-                        if($userInCourse){
+                        $userInCourse = CourseMember::where('course_id', $request->input('course'))
+                            ->where('user_id', $userId)
+                            ->first();
+                        if ($userInCourse) {
                             $channelId = $userInCourse->channel_id;
                             $channelId = $userInCourse->channel_id;
                             $channels = [$channelId];
                             $channels = [$channelId];
                         }
                         }
-                    }else if($request->get('view')==="answer"){
+                    } else if ($request->input('view') === "answer") {
                         /**
                         /**
                          * 显示答案
                          * 显示答案
                          * 算法:查询course 答案 channel
                          * 算法:查询course 答案 channel
                          */
                          */
-                        $channelId = Course::where('id',$request->get('course'))->value('channel_id');
+                        $channelId = Course::where('id', $request->input('course'))->value('channel_id');
                         $channels = [$channelId];
                         $channels = [$channelId];
-                    }else{
+                    } else {
                         //显示答案
                         //显示答案
-                        $channelId = Course::where('id',$request->get('course'))->value('channel_id');
+                        $channelId = Course::where('id', $request->input('course'))->value('channel_id');
                         $channels = [$channelId];
                         $channels = [$channelId];
                     }
                     }
-                }else{
-                    $channelId = Course::where('id',$request->get('course'))->value('channel_id');
+                } else {
+                    $channelId = Course::where('id', $request->input('course'))->value('channel_id');
                     $channels = [$channelId];
                     $channels = [$channelId];
                 }
                 }
             }
             }
 
 
-            $mode = $request->get('mode','read');
-            $format = $request->get('format','react');
+            $mode = $request->input('mode', 'read');
+            $format = $request->input('format', 'react');
 
 
             $htmlRender = new MdRender([
             $htmlRender = new MdRender([
                 'mode' => $mode,
                 'mode' => $mode,
-                'format'=> $format,
+                'format' => $format,
                 'footnote' => true,
                 'footnote' => true,
-                'origin' => $request->get('origin',true),
-                'paragraph' => $request->get('paragraph',false),
+                'origin' => $request->input('origin', true),
+                'paragraph' => $request->input('paragraph', false),
             ]);
             ]);
             //Log::debug('article render',['content'=>$this->content,'format'=>$format,'html'=>$html]);
             //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');
+            $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;
         return $data;

+ 14 - 14
api-v12/app/Http/Resources/CourseMemberResource.php

@@ -18,24 +18,24 @@ class CourseMemberResource extends JsonResource
     public function toArray($request)
     public function toArray($request)
     {
     {
         $data = [
         $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,
+            "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){
+        if ($this->channel_id) {
             $channel = ChannelApi::getById($this->channel_id);
             $channel = ChannelApi::getById($this->channel_id);
-            if($channel){
-               $data['channel'] =  $channel;
+            if ($channel) {
+                $data['channel'] =  $channel;
             }
             }
         }
         }
-        if(!empty($request->get('request_course'))){
+        if (!empty($request->input('request_course'))) {
             $course = Course::find($this->course_id);
             $course = Course::find($this->course_id);
             $data['course'] =  $course;
             $data['course'] =  $course;
         }
         }

+ 59 - 59
api-v12/app/Http/Resources/CourseResource.php

@@ -25,99 +25,99 @@ class CourseResource extends JsonResource
     public function toArray($request)
     public function toArray($request)
     {
     {
         $data = [
         $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,
+            "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),
             "studio" => StudioApi::getById($this->studio_id),
-            "created_at"=> $this->created_at,
-            "updated_at"=> $this->updated_at,
+            "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['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();
+        $data['members'] = CourseMember::where('course_id', $this->id)
+            ->where('is_current', true)
+            ->select(['role', 'status'])
+            ->get();
         $user = AuthApi::current($request);
         $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 ($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 ($this->cover) {
+            $thumb = str_replace('.jpg', '_m.jpg', $this->cover);
             if (App::environment('local')) {
             if (App::environment('local')) {
-                $data['cover_url'] = [Storage::url($this->cover),Storage::url($thumb)];
-            }else{
+                $data['cover_url'] = [Storage::url($this->cover), Storage::url($thumb)];
+            } else {
                 $data['cover_url'] = [
                 $data['cover_url'] = [
                     Storage::temporaryUrl($this->cover, now()->addDays(6)),
                     Storage::temporaryUrl($this->cover, now()->addDays(6)),
                     Storage::temporaryUrl($thumb, now()->addDays(6)),
                     Storage::temporaryUrl($thumb, now()->addDays(6)),
                 ];
                 ];
             }
             }
         }
         }
-        if(Str::isUuid($this->cover)){
+        if (Str::isUuid($this->cover)) {
             $coverId = Attachment::find($this->cover);
             $coverId = Attachment::find($this->cover);
             $cover_url = [];
             $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');
+            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;
                 $data['cover_url'] = $cover_url;
             }
             }
         }
         }
 
 
-        $textbook = Collection::where('uid',$this->anthology_id)->select(['uid','title','owner'])->first();
-        if($textbook){
+        $textbook = Collection::where('uid', $this->anthology_id)->select(['uid', 'title', 'owner'])->first();
+        if ($textbook) {
             $data['anthology_id'] = $textbook->uid;
             $data['anthology_id'] = $textbook->uid;
             $data['anthology_title'] = $textbook->title;
             $data['anthology_title'] = $textbook->title;
             $data['anthology_owner'] = StudioApi::getById($textbook->owner);
             $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){
+        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_name'] = $channel->name;
                 $data['channel_owner'] = StudioApi::getById($channel->owner_uid);
                 $data['channel_owner'] = StudioApi::getById($channel->owner_uid);
             }
             }
         }
         }
 
 
-        if($request->get('view') === "study" || $request->get('view') === "teach"){
+        if ($request->input('view') === "study" || $request->input('view') === "teach") {
             $user = AuthApi::current($request);
             $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){
+            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'] = $course_member->status;
                     $data['my_status_id'] = $course_member->id;
                     $data['my_status_id'] = $course_member->id;
                 }
                 }
             }
             }
-        }else{
+        } else {
             //计算待审核
             //计算待审核
-            $data['count_progressing'] = CourseMember::where('course_id',$this->id)
-                                                ->where('status',"invited")
-                                                ->where('is_current',true)
-                                                ->count();
+            $data['count_progressing'] = CourseMember::where('course_id', $this->id)
+                ->where('status', "invited")
+                ->where('is_current', true)
+                ->count();
         }
         }
 
 
         return $data;
         return $data;

+ 17 - 17
api-v12/app/Http/Resources/NissayaEndingResource.php

@@ -18,27 +18,27 @@ class NissayaEndingResource extends JsonResource
     public function toArray($request)
     public function toArray($request)
     {
     {
         $data = [
         $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,
+            "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')) ;
+        if ($this->lang === 'my') {
+            $uiLang = strtolower($request->input('ui-lang', 'en'));
             $term_channel = ChannelApi::getSysChannel("_System_Grammar_Term_{$uiLang}_");
             $term_channel = ChannelApi::getSysChannel("_System_Grammar_Term_{$uiLang}_");
-            if($term_channel){
-                $term = DhammaTerm::where("word",$this->ending)
-                                            ->where('channal',$term_channel)
-                                            ->first();
+            if ($term_channel) {
+                $term = DhammaTerm::where("word", $this->ending)
+                    ->where('channal', $term_channel)
+                    ->first();
                 $data['term_channel'] = $term_channel;
                 $data['term_channel'] = $term_channel;
-                if($term){
+                if ($term) {
                     $data['term_id'] = $term->guid;
                     $data['term_id'] = $term->guid;
                 }
                 }
             }
             }

+ 21 - 21
api-v12/app/Http/Resources/RelationResource.php

@@ -18,32 +18,32 @@ class RelationResource extends JsonResource
     public function toArray($request)
     public function toArray($request)
     {
     {
         $data = [
         $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,
+            "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')){
+        if (!$request->has('vocabulary')) {
             //TODO 默认英文
             //TODO 默认英文
             $data["editor"] = UserApi::getByUuid($this->editor_id);
             $data["editor"] = UserApi::getByUuid($this->editor_id);
-            $lang = $request->get('ui-lang');
+            $lang = $request->input('ui-lang');
 
 
-            $uiLang = strtolower($request->get('ui-lang','zh-Hans')) ;
+            $uiLang = strtolower($request->input('ui-lang', 'zh-Hans'));
             $term_channel = ChannelApi::getSysChannel("_System_Grammar_Term_{$uiLang}_");
             $term_channel = ChannelApi::getSysChannel("_System_Grammar_Term_{$uiLang}_");
-            if($term_channel){
+            if ($term_channel) {
                 $data['category_channel'] = $term_channel;
                 $data['category_channel'] = $term_channel;
-                if(!empty($this->category)){
-                    $term = DhammaTerm::where("word",$this->category)
-                                                ->where('channal',$term_channel)
-                                                ->first();
-                    if($term){
+                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']['channelId'] = $term_channel;
                         $data['category_term']['word'] = $term->word;
                         $data['category_term']['word'] = $term->word;
                         $data['category_term']['id'] = $term->guid;
                         $data['category_term']['id'] = $term->guid;
@@ -51,10 +51,10 @@ class RelationResource extends JsonResource
                     }
                     }
                 }
                 }
                 $data['name_channel'] = $term_channel;
                 $data['name_channel'] = $term_channel;
-                $term_name = DhammaTerm::where("word",$this->name)
-                    ->where('channal',$term_channel)
+                $term_name = DhammaTerm::where("word", $this->name)
+                    ->where('channal', $term_channel)
                     ->first();
                     ->first();
-                if($term_name){
+                if ($term_name) {
                     $data['name_term']['channelId'] = $term_channel;
                     $data['name_term']['channelId'] = $term_channel;
                     $data['name_term']['word'] = $term_name->word;
                     $data['name_term']['word'] = $term_name->word;
                     $data['name_term']['id'] = $term_name->guid;
                     $data['name_term']['id'] = $term_name->guid;

+ 20 - 20
api-v12/app/Http/Resources/SearchPaliWbwResource.php

@@ -16,41 +16,41 @@ class SearchPaliWbwResource extends JsonResource
     public function toArray($request)
     public function toArray($request)
     {
     {
         $data = [
         $data = [
-            "book"=>$this->book,
-            "paragraph"=> $this->paragraph,
+            "book" => $this->book,
+            "paragraph" => $this->paragraph,
         ];
         ];
-        if(isset($this->rank)){
+        if (isset($this->rank)) {
             $data["rank"] = $this->rank;
             $data["rank"] = $this->rank;
         }
         }
-        $paliText = PaliText::where('book',$this->book)
-                    ->where('paragraph',$this->paragraph)
-                    ->first();
-        if($paliText){
+        $paliText = PaliText::where('book', $this->book)
+            ->where('paragraph', $this->paragraph)
+            ->first();
+        if ($paliText) {
             $data['path'] = json_decode($paliText->path);
             $data['path'] = json_decode($paliText->path);
-            if($paliText->level<100){
+            if ($paliText->level < 100) {
                 $data["paliTitle"] = $paliText->toc;
                 $data["paliTitle"] = $paliText->toc;
-            }else{
-                $data["paliTitle"] = PaliText::where('book',$this->book)
-                                            ->where('paragraph',$paliText->parent)
-                                            ->value('toc');
+            } else {
+                $data["paliTitle"] = PaliText::where('book', $this->book)
+                    ->where('paragraph', $paliText->parent)
+                    ->value('toc');
             }
             }
-            $keyWords = explode(',',$request->get('key'));
-            $keyWordsUpper=$keyWords;
+            $keyWords = explode(',', $request->input('key'));
+            $keyWordsUpper = $keyWords;
             foreach ($keyWords as $key => $word) {
             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");
+                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) {
             foreach ($keyWords as $key => $word) {
-                $keyWordsUpper[] = mb_strtoupper(mb_substr($word,0,1,"UTF-8"),"UTF-8").mb_substr($word,1,null,"UTF-8");
+                $keyWordsUpper[] = mb_strtoupper(mb_substr($word, 0, 1, "UTF-8"), "UTF-8") . mb_substr($word, 1, null, "UTF-8");
             }
             }
             $keyReplace = array();
             $keyReplace = array();
             foreach ($keyWordsUpper as $key => $word) {
             foreach ($keyWordsUpper as $key => $word) {
                 $keyReplace[] = "<span class='hl'>{$word}</span>";
                 $keyReplace[] = "<span class='hl'>{$word}</span>";
             }
             }
-            $data["highlight"] = str_replace($keyWordsUpper,$keyReplace,$paliText->html);
+            $data["highlight"] = str_replace($keyWordsUpper, $keyReplace, $paliText->html);
         }
         }
         return $data;
         return $data;
     }
     }

+ 15 - 15
api-v12/app/Http/Resources/SentPrResource.php

@@ -21,25 +21,25 @@ class SentPrResource extends JsonResource
         //获取用户信息
         //获取用户信息
         $user = AuthApi::current($request);
         $user = AuthApi::current($request);
         $role = 'reader';
         $role = 'reader';
-        if($user && $user["user_uid"] === $this->editor_uid ){
+        if ($user && $user["user_uid"] === $this->editor_uid) {
             $role = 'owner';
             $role = 'owner';
         }
         }
         $channel = ChannelApi::getById($this->channel_uid);
         $channel = ChannelApi::getById($this->channel_uid);
-        $mode = $request->get("mode",'read');
+        $mode = $request->input("mode", 'read');
         return [
         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,
+            "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,
         ];
         ];
     }
     }
 }
 }

+ 43 - 41
api-v12/app/Http/Resources/SentResource.php

@@ -22,65 +22,67 @@ class SentResource extends JsonResource
     public function toArray($request)
     public function toArray($request)
     {
     {
         $channel = ChannelApi::getById($this->channel_uid);
         $channel = ChannelApi::getById($this->channel_uid);
-        if(!$channel){
-            Log::error('channel left',['data'=>$this->channel_uid,'uid'=>$this->uid]);
+        if (!$channel) {
+            Log::error('channel left', ['data' => $this->channel_uid, 'uid' => $this->uid]);
         }
         }
-        if($request->get('mode','read')==="read"){
+        if ($request->input('mode', 'read') === "read") {
             $mode = 'read';
             $mode = 'read';
-        }else{
+        } else {
             $mode = 'edit';
             $mode = 'edit';
         }
         }
         $data = [
         $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,
-            ];
+            "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){
+        if ($channel) {
             $data['channel'] = $channel;
             $data['channel'] = $channel;
             $data['studio'] = StudioApi::getById($channel["studio_id"]);
             $data['studio'] = StudioApi::getById($channel["studio_id"]);
         }
         }
-        if($request->has('channels')){
-            $channels = explode(',',$request->get('channels'));
-        }else{
+        if ($request->has('channels')) {
+            $channels = explode(',', $request->input('channels'));
+        } else {
             $channels = [$this->channel_uid];
             $channels = [$this->channel_uid];
         }
         }
         //TODO 找出channel id = '' 的原因
         //TODO 找出channel id = '' 的原因
-        $mChannels=array();
+        $mChannels = array();
         foreach ($channels as $key => $value) {
         foreach ($channels as $key => $value) {
-            if(Str::isUuid($value)){
+            if (Str::isUuid($value)) {
                 $mChannels[] = $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->input('html', true)) {
+            $data['html'] = MdRender::render(
+                $this->content,
+                $mChannels,
+                null,
+                $mode,
+                $channel['type'],
+                $this->content_type,
+                $request->input('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 ($request->input('mode') === "edit" || $request->input('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;
+        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;
         return $data;
     }
     }

+ 4 - 4
api-v12/app/Http/Resources/SentSimResource.php

@@ -22,12 +22,12 @@ class SentSimResource extends JsonResource
     {
     {
         //获取实际句子信息
         //获取实际句子信息
         $sent = PaliSentence::find($this->sent2);
         $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;
+        $channels = explode(',', $request->input('channels'));
+        $mode = explode(',', $request->input('mode', 'read'));
+        $sentId = $sent->book . '-' . $sent->paragraph . '-' . $sent->word_begin . '-' . $sent->word_end;
         $Sent = new CorpusController();
         $Sent = new CorpusController();
         $tpl =
         $tpl =
-        $data['sent'] = $Sent->getSentTpl($sentId,$channels,$mode);
+            $data['sent'] = $Sent->getSentTpl($sentId, $channels, $mode);
         $data['sim'] = $this->sim;
         $data['sim'] = $this->sim;
         return $data;
         return $data;
     }
     }

+ 2 - 2
api-v12/app/Http/Resources/TaskResource.php

@@ -27,8 +27,8 @@ class TaskResource extends JsonResource
             'mode' => 'read',
             'mode' => 'read',
             'format' => 'react',
             'format' => 'react',
             'footnote' => true,
             'footnote' => true,
-            'origin' => $request->get('origin', true),
-            'paragraph' => $request->get('paragraph', false),
+            'origin' => $request->input('origin', true),
+            'paragraph' => $request->input('paragraph', false),
         ]);
         ]);
         $data = [
         $data = [
             'id' => $this->id,
             'id' => $this->id,

+ 4 - 4
api-v12/app/Http/Resources/TermResource.php

@@ -42,8 +42,8 @@ class TermResource extends JsonResource
         ];
         ];
 
 
 
 
-        if ($request->has('channel') && !empty($request->get('channel'))) {
-            $channels = explode('_', $request->get('channel'));
+        if ($request->has('channel') && !empty($request->input('channel'))) {
+            $channels = explode('_', $request->input('channel'));
         } else {
         } else {
             if (!empty($this->channal) && Str::isUuid($this->channal)) {
             if (!empty($this->channal) && Str::isUuid($this->channal)) {
                 $channelId = $this->channal;
                 $channelId = $this->channal;
@@ -65,7 +65,7 @@ class TermResource extends JsonResource
         if (!empty($this->note)) {
         if (!empty($this->note)) {
             $mdRender = new MdRender(
             $mdRender = new MdRender(
                 [
                 [
-                    'mode' => $request->get('mode', 'read'),
+                    'mode' => $request->input('mode', 'read'),
                     'format' => 'react',
                     'format' => 'react',
                     'studioId' => $this->owner,
                     'studioId' => $this->owner,
                 ]
                 ]
@@ -95,7 +95,7 @@ class TermResource extends JsonResource
         if (isset($summaryContent)) {
         if (isset($summaryContent)) {
             $mdRender = new MdRender(
             $mdRender = new MdRender(
                 [
                 [
-                    'mode' => $request->get('mode', 'read'),
+                    'mode' => $request->input('mode', 'read'),
                     'format' => 'text',
                     'format' => 'text',
                     'studioId' => $this->owner,
                     'studioId' => $this->owner,
                 ]
                 ]

+ 27 - 27
api-v12/app/Http/Resources/TocResource.php

@@ -16,43 +16,43 @@ class TocResource extends JsonResource
     public function toArray($request)
     public function toArray($request)
     {
     {
         $data = [
         $data = [
-            "book"=>$this->book,
-            "paragraph"=> $this->paragraph,
-            "pali_title"=> $this->toc,
-            "level"=>$this->level
+            "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)){
+        $title = ProgressChapter::where('book', $this->book)
+            ->where('para', $this->paragraph)
+            ->where('lang', 'zh')
+            ->whereNotNull('title')
+            ->value('title');
+        if (!empty($title)) {
             $data['title'] = $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'));
+        if ($request->has('channels')) {
+            if (strpos($request->input('channels'), ',') === FALSE) {
+                $channels = explode('_', $request->input('channels'));
+            } else {
+                $channels = explode(',', $request->input('channels'));
             }
             }
-            $title = ProgressChapter::where('book',$this->book)
-                                ->where('para',$this->paragraph)
-                                ->where('channel_id',$channels[0])
-                                ->whereNotNull('title')
-                                ->value('title');
-            if(!empty($title)){
+            $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;
                 $data['title'] = $title;
             }
             }
             //查询完成度
             //查询完成度
             foreach ($channels as $key => $channel) {
             foreach ($channels as $key => $channel) {
-                $progress = ProgressChapter::where('book',$this->book)
-                                ->where('para',$this->paragraph)
-                                ->where('channel_id',$channel)
-                                ->value('progress');
-                if($progress){
+                $progress = ProgressChapter::where('book', $this->book)
+                    ->where('para', $this->paragraph)
+                    ->where('channel_id', $channel)
+                    ->value('progress');
+                if ($progress) {
                     $data['progress'][] = $progress;
                     $data['progress'][] = $progress;
-                }else{
+                } else {
                     $data['progress'][] = 0;
                     $data['progress'][] = 0;
                 }
                 }
             }
             }

+ 22 - 22
api-v12/app/Http/Resources/UserDictResource.php

@@ -19,34 +19,34 @@ class UserDictResource extends JsonResource
     public function toArray($request)
     public function toArray($request)
     {
     {
         $data = [
         $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,
+            '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']);
+        if (!empty($this->note)) {
+            $mdRender = new MdRender(['format' => 'react', 'lang' => 'zh-Hans']);
             $data['note'] = $mdRender->convert($this->note);
             $data['note'] = $mdRender->convert($this->note);
         }
         }
-        if($request->get('view')==='community'){
+        if ($request->input('view') === 'community') {
             $data['editor'] = UserApi::getById($this->creator_id);
             $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);
+            $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();
+        if ($request->input('view') === 'all') {
+            $data['dict'] = DictInfo::where('id', $this->dict_id)->select(['id', 'name', 'shortname'])->first();
         }
         }
         return $data;
         return $data;
     }
     }

+ 1 - 1
api-v12/app/Http/Resources/VocabularyResource.php

@@ -20,7 +20,7 @@ class VocabularyResource extends JsonResource
             "word" => $this['word'],
             "word" => $this['word'],
             "count" => $this['count'],
             "count" => $this['count'],
             "strlen" => $this['strlen'],
             "strlen" => $this['strlen'],
-            "meaning" => $dictMeaning->get($this['word'], $request->get("lang", "zh-Hans")),
+            "meaning" => $dictMeaning->get($this['word'], $request->input("lang", "zh-Hans")),
         ];
         ];
     }
     }
 }
 }