Docter.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 order()
  36. {
  37. return $this->hasMany(Order::class,'docter_id','id');
  38. }
  39. public function doctertimes(){
  40. return $this->belongsTo(Doctertimes::class);
  41. }
  42. public function getIsCollectAttribute()
  43. {
  44. if (!empty(request()->header('token'))) {
  45. $user = User::getUserByToken();
  46. if (Collection::where('user_id', $user['id'])->where('docter_id', $this->id)->exists()) {
  47. return 1;
  48. }
  49. }
  50. return 0;
  51. }
  52. public function serviceapplys()
  53. {
  54. return $this->hasOne(Serviceapplys::class);
  55. }
  56. }