Organization.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zilongs
  5. * Date: 20-9-29
  6. * Time: 下午2:35
  7. */
  8. namespace App\Models;
  9. class Organization extends BaseModel
  10. {
  11. CONST HOSPITOAL = 1, ORGANIZATION = 2, CLINC = 3;
  12. protected static $_getType = [
  13. self::HOSPITOAL => '医院',
  14. self::ORGANIZATION => '机构',
  15. self::CLINC => '医院',
  16. ];
  17. public static function getType()
  18. {
  19. return self::$_getType;
  20. }
  21. public function docter()
  22. {
  23. $ret = $this->belongsToMany(Docter::class)->where('status', 1);
  24. $req = request()->post();
  25. if (!empty($req['schedule_type'])) {
  26. $ret->where('type', $req['schedule_type']);
  27. }
  28. return $ret;
  29. }
  30. public function vaccines()
  31. {
  32. return $this->belongsToMany(Vaccines::class,'vaccines_id');
  33. }
  34. public function user()
  35. {
  36. return $this->hasOne(CdmsUsers::class,'org_id','id');
  37. }
  38. public function communityNotice()
  39. {
  40. return $this->hasOne(CommunityNotice::class, 'organization_id', 'id');
  41. }
  42. public function offices(){
  43. return $this->hasMany(Office::class,'org_id','id');
  44. }
  45. public function docterOrganization()
  46. {
  47. return $this->hasMany(DocterOrganization::class)->where('state', 1)->where('authentication_end_time', '>', time());
  48. }
  49. }