Ver Fonte

add name_term

visuddhinanda há 2 anos atrás
pai
commit
139eda4cdd
1 ficheiros alterados com 13 adições e 3 exclusões
  1. 13 3
      app/Http/Resources/RelationResource.php

+ 13 - 3
app/Http/Resources/RelationResource.php

@@ -36,9 +36,9 @@ class RelationResource extends JsonResource
         if($term_channel){
             $data['category_channel'] = $term_channel;
             if(!empty($this->category)){
-            $term = DhammaTerm::where("word",$this->category)
-                                        ->where('channal',$term_channel)
-                                        ->first();
+                $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;
@@ -46,6 +46,16 @@ class RelationResource extends JsonResource
                     $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;
+            }
         }