zilong há 4 anos atrás
pai
commit
5624eb4d56

+ 30 - 0
app/Http/Controllers/Api/V1/FeedbackController.php

xqd
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-11-4
+ * Time: 下午4:29
+ */
+
+namespace App\Http\Controllers\Api\V1;
+
+use App\Models\Feedback;
+
+class FeedbackController extends AuthController
+{
+    public function sumitFeedback()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'content|反馈内容' => 'required|max:500'
+        ]);
+        $user = $this->user;
+
+        Feedback::create([
+            'user_id' => $user['id'],
+            'content' => $req['content'],
+        ]);
+
+        return out();
+    }
+}

+ 4 - 1
app/Http/Controllers/Api/V1/PatientController.php

xqd xqd
@@ -38,6 +38,9 @@ class PatientController extends AuthController
     {
         $user = $this->user;
         $data = Patient::where('user_id', $user['id'])->orderBy('id', 'desc')->paginate();
+        foreach ($data as $k => $v) {
+            $v->append(['order_num', 'pack_docter_num', 'perfectd_degree']);
+        }
         return out($data);
     }
 
@@ -50,7 +53,7 @@ class PatientController extends AuthController
         $user = $this->user;
 
         $data = [];
-        $data['patient'] = Patient::where('id', $req['patient_id'])->where('user_id', $user['id'])->first();
+        $data['patient'] = Patient::where('id', $req['patient_id'])->where('user_id', $user['id'])->first()->append(['order_num', 'pack_docter_num', 'perfectd_degree']);
 
         $data['orders']['cases'] = Order::with(['docter.office', 'docter.qualification', 'organization.docter'])->where('user_id', $user['id'])->where('patient_id', $req['patient_id'])->whereIn('order_status', [2,3])->where('product_type', '<', 6)->orderBy('id', 'desc')->get();
         $data['orders']['service_packs'] = Order::with('orderPack')->where('user_id', $user['id'])->where('patient_id', $req['patient_id'])->whereIn('order_status', [2,3])->where('product_type', 6)->orderBy('id', 'desc')->get();

+ 17 - 0
app/Models/Feedback.php

xqd
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-11-4
+ * Time: 下午4:28
+ */
+
+namespace App\Models;
+
+class Feedback extends BaseModel
+{
+    public function getTable()
+    {
+        return 'feedbacks';
+    }
+}

+ 16 - 1
app/Models/Patient.php

xqd
@@ -24,7 +24,22 @@ class Patient extends BaseModel
 
     public function getPackDocterNumAttribute()
     {
-        $team_ids = OrderPack::join('order', 'order.id', '=', 'order_pack.order_id')->where('order.patient_id', $this->id)->where('order.payment_status', 2)->where('order.product_type', 7)->pluck('order_pack.team_id')->toArray();
+        $team_ids = OrderPack::join('orders', 'orders.id', '=', 'order_packs.order_id')->where('orders.patient_id', $this->id)->where('orders.payment_status', 2)->where('orders.product_type', 7)->pluck('order_packs.team_id')->toArray();
         return TeamDocter::whereIn('team_id', $team_ids)->count();
     }
+
+    public function getPerfectdDegreeAttribute()
+    {
+        $field = ['name', 'sex', 'avatar', 'birthday', 'relationship_type', 'card_number'];
+        $total = count($field);
+        $fill = 0;
+        foreach ($field as $k => $v) {
+            if (!empty($this->$v)) {
+                $fill++;
+            }
+        }
+
+        $text = round($fill/$total*100) . '%';
+        return $text;
+    }
 }