Docter.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zilongs
  5. * Date: 20-9-29
  6. * Time: 上午11:12
  7. */
  8. namespace App\Models;
  9. class Docter extends BaseModel
  10. {
  11. protected $casts = [
  12. 'label' => 'json',
  13. ];
  14. protected $appends = ['is_collect'];
  15. public function office()
  16. {
  17. return $this->belongsTo(Office::class)->select(['id', 'name']);
  18. }
  19. public function qualification()
  20. {
  21. return $this->belongsTo(Qualification::class)->select(['id', 'name']);
  22. }
  23. public function DocterOrganization()
  24. {
  25. return $this->belongsTo(DocterOrganization::class,'docter_id','id');
  26. }
  27. public function evaluate()
  28. {
  29. return $this->hasMany(Evaluate::class)->where('status', 2);
  30. }
  31. public function teamdocter()
  32. {
  33. return $this->hasOne(TeamDocter::class);
  34. }
  35. public function getIsCollectAttribute()
  36. {
  37. if (!empty(request()->header('token'))) {
  38. $user = User::getUserByToken();
  39. if (Collection::where('user_id', $user['id'])->where('docter_id', $this->id)->exists()) {
  40. return 1;
  41. }
  42. }
  43. return 0;
  44. }
  45. }