visuddhinanda 2 роки тому
батько
коміт
5f74975ca1

+ 13 - 1
app/Http/Controllers/RelationController.php

@@ -20,7 +20,9 @@ class RelationController extends Controller
     public function index(Request $request)
     {
         //
-        $table = Relation::select(['id','name','case','from','to','category','editor_id','updated_at','created_at']);
+        $table = Relation::select(['id','name','case','from','to',
+                                    'category','editor_id','match',
+                                    'updated_at','created_at']);
         if(($request->has('case'))){
             $table = $table->whereIn('case', explode(",",$request->get('case')) );
         }
@@ -73,6 +75,11 @@ class RelationController extends Controller
         }else{
             $new->to = null;
         }
+        if($request->has('match')){
+            $new->match = json_encode($request->get('match'),JSON_UNESCAPED_UNICODE);
+        }else{
+            $new->match = null;
+        }
         $new->editor_id = $user['user_uid'];
         $new->save();
         return $this->ok(new RelationResource($new));
@@ -121,6 +128,11 @@ class RelationController extends Controller
         }else{
             $relation->to = null;
         }
+        if($request->has('match')){
+            $relation->match = json_encode($request->get('match'),JSON_UNESCAPED_UNICODE);
+        }else{
+            $relation->match = null;
+        }
         $relation->editor_id = $user['user_uid'];
         $relation->save();
         return $this->ok(new RelationResource($relation));

+ 1 - 0
app/Http/Resources/RelationResource.php

@@ -23,6 +23,7 @@ class RelationResource extends JsonResource
             "case"=> $this->case,
             "from"=> json_decode($this->from),
             "to"=> json_decode($this->to),
+            "match"=> json_decode($this->match),
             "category"=> $this->category,
             "editor"=> UserApi::getByUuid($this->editor_id),
             "created_at"=> $this->created_at,