123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- /**
- * Created by PhpStorm.
- * User: zilongs
- * Date: 20-10-1
- * Time: 上午12:10
- */
- namespace App\Models;
- class Patient extends BaseModel
- {
- protected $appends = ['age'];
- public function getAgeAttribute()
- {
- return birthday_to_age($this->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'];
- $total = count($field);
- $fill = 0;
- foreach ($field as $k => $v) {
- if (!empty($this->$v)) {
- $fill++;
- }
- }
- $text = round($fill/$total*100) . '%';
- return $text;
- }
- }
|