Explorar el Código

添加 wbw信息

visuddhinanda hace 1 año
padre
commit
2e568b2dbc
Se han modificado 1 ficheros con 18 adiciones y 1 borrados
  1. 18 1
      app/Http/Resources/DiscussionCountResource.php

+ 18 - 1
app/Http/Resources/DiscussionCountResource.php

@@ -3,6 +3,7 @@
 namespace App\Http\Resources;
 namespace App\Http\Resources;
 
 
 use Illuminate\Http\Resources\Json\JsonResource;
 use Illuminate\Http\Resources\Json\JsonResource;
+use App\Models\Wbw;
 
 
 class DiscussionCountResource extends JsonResource
 class DiscussionCountResource extends JsonResource
 {
 {
@@ -14,6 +15,22 @@ class DiscussionCountResource extends JsonResource
      */
      */
     public function toArray($request)
     public function toArray($request)
     {
     {
-        return parent::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;
     }
     }
 }
 }