'json', ]; protected $appends = ['is_collect', 'label_texts', 'is_can_phone', 'is_can_chat', 'can_appoint_days']; public function office() { return $this->belongsTo(Office::class)->select(['id', 'name']); } public function qualification() { return $this->belongsTo(Qualification::class)->select(['id', 'name']); } public function DocterOrganization() { return $this->belongsTo(DocterOrganization::class,'docter_id','id'); } public function evaluate() { return $this->hasMany(Evaluate::class)->where('status', 2); } public function teamdocter() { return $this->hasOne(TeamDocter::class); } public function order() { return $this->hasMany(Order::class,'docter_id','id'); } public function DocterTimes(){ return $this->belongsTo(DocterTimes::class); } public function getIsCollectAttribute() { if (!empty(request()->header('token'))) { $user = User::getUserByToken(); if (Collection::where('user_id', $user['id'])->where('docter_id', $this->id)->exists()) { return 1; } } return 0; } public function serviceapplys() { return $this->hasOne(Serviceapplys::class); } public function serviceapply() { return $this->hasMany(Serviceapplys::class); } public function getLabelTextsAttribute() { $data = []; if (!empty($this->label) && is_array($this->label)) { $data = DocterLabel::select(['label_name'])->whereIn('id', $this->label)->where('status', 1)->get()->toArray(); } return $data; } public function organization() { return $this->belongsToMany(Organization::class); } public function getChatPriceAttribute() { $base_price = DocterTimes::where('docter_id', $this->id)->where('type', 2)->value('base_price'); return $base_price*100; } public function getPhonePriceAttribute() { $base_price = DocterTimes::where('docter_id', $this->id)->where('type', 1)->value('base_price'); return $base_price*100; } public function getAppointPriceAttribute() { $appoint_price = DocterSetting::where('docter_id', $this->id)->where('type', 1)->where('status', 2)->orderBy('id', 'asc')->value('appoint_price'); return $appoint_price*100; } public function getIsCanPhoneAttribute() { if ($this->is_phone == 1) { $now_line = (int)date('Hi'); if (DocterServiceTime::where('docter_id', $this->id)->where('type', 1)->where('start_time_line', '<=', $now_line)->where('end_time_line', '>', $now_line)->exists()) { return 1; } } return 0; } public function getIsCanChatAttribute() { if ($this->is_chat == 1) { $now_line = (int)date('Hi'); if (DocterServiceTime::where('docter_id', $this->id)->where('type', 2)->where('start_time_line', '<=', $now_line)->where('end_time_line', '>', $now_line)->exists()) { return 1; } } return 0; } public function getPhoneMinutesAttribute() { if (!isset($this->phone_minutes) || empty($this->phone_minutes)) { return SystemConfig::where('group', 'docter_config')->where('key', 'phone_base_time')->value('value'); } return $this->phone_minutes; } public function getCanAppointDaysAttribute() { $show_days = DocterSetting::where('docter_id', $this->id)->where('type', 1)->value('show_days'); return !empty($show_days) ? $show_days : 0; } }