12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- /**
- * Created by PhpStorm.
- * User: zilongs
- * Date: 20-9-29
- * Time: 上午11:12
- */
- namespace App\Models;
- class Docter extends BaseModel
- {
- protected $casts = [
- 'label' => 'json',
- ];
- protected $appends = ['is_collect'];
- 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);
- }
- }
|