Pārlūkot izejas kodu

add source_type source_id

visuddhinanda 3 dienas atpakaļ
vecāks
revīzija
e139247e94

+ 8 - 3
api-v13/app/Http/Controllers/ChannelController.php

@@ -270,7 +270,7 @@ class ChannelController extends Controller
                     if ($value->owner_uid === $user['user_uid']) {
                         $value['role'] = 'owner';
                     } else {
-                        if (isset($channelById[$value->uid])) {
+                        if (isset($channelById) && isset($channelById[$value->uid])) {
                             switch ($channelById[$value->uid]['power']) {
                                 case 10:
                                     # code...
@@ -588,8 +588,7 @@ class ChannelController extends Controller
     public function show($id)
     {
         //
-        $indexCol = ['uid', 'name', 'summary', 'type', 'owner_uid', 'lang', 'is_system', 'status', 'updated_at', 'created_at'];
-        $channel = Channel::where("uid", $id)->select($indexCol)->first();
+        $channel = Channel::find($id);
         if (!$channel) {
             return $this->error('no res');
         }
@@ -646,6 +645,12 @@ class ChannelController extends Controller
         $channel->summary = $request->input('summary');
         $channel->lang = $request->input('lang');
         $channel->status = $request->input('status');
+        if ($request->has('source_type')) {
+            $channel->source_type = $request->input('source_type');
+        }
+        if ($request->has('source_id')) {
+            $channel->source_id = $request->input('source_id');
+        }
         $channel->save();
         return $this->ok($channel);
     }

+ 8 - 0
api-v13/app/Http/Resources/ChannelResource.php

@@ -26,7 +26,15 @@ class ChannelResource extends JsonResource
             "status" => $this->status,
             "created_at" => $this->created_at,
             "updated_at" => $this->updated_at,
+            "source_type" => $this->source_type,
+            "source_id" => $this->source_id,
         ];
+        if (isset($this->source_type)) {
+            $data['source_type'] = $this->source_type;
+        }
+        if (isset($this->source_id)) {
+            $data['source_id'] = $this->source_id;
+        }
         if (isset($this->progress)) {
             $data["progress"] = $this->progress;
         }