birthday); } public function getOrderNumAttribute() { return Order::where('patient_id', $this->id)->where('payment_status', 2)->where('product_type', '<', 6)->count(); } public function getPackDocterNumAttribute() { $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', 'email', 'phone', 'social_card_number', 'born_hospital', 'guardian_name', 'address']; $total = count($field); $fill = 0; foreach ($field as $k => $v) { if (!empty($this->$v)) { $fill++; } } $text = round($fill/$total*100) . '%'; return $text; } public function users() { return $this->belongsTo(User::class,'user_id','id'); } public function userspatient() { return $this->belongsTo(User::class,'user_id','id'); } public function order() { return $this->hasMany(Order::class); } public function user() { return $this->belongsTo(User::class); } public function orderPatient() { return $this->hasOne(OrderPatient::class,'patient_id','id'); } public function getRelationshipTypeTextAttribute() { return config('config.relationship_type_map')[$this->relationship_type] ?? ''; } }