'json', ]; protected $appends = ['is_collect', 'label_texts']; 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; } }