1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- /**
- * Created by PhpStorm.
- * User: zilongs
- * Date: 20-9-29
- * Time: 下午2:35
- */
- namespace App\Models;
- class Organization extends BaseModel
- {
- CONST HOSPITOAL = 1, ORGANIZATION = 2, CLINC = 3;
- protected $appends = ['can_vaccine_days', 'can_nurse_days'];
- protected static $_getType = [
- self::HOSPITOAL => '医院',
- self::ORGANIZATION => '机构',
- self::CLINC => '医院',
- ];
- public static function getType()
- {
- return self::$_getType;
- }
- public function docter()
- {
- $ret = $this->belongsToMany(Docter::class)->where('status', 1);
- $req = request()->post();
- if (!empty($req['schedule_type'])) {
- $ret->where('type', $req['schedule_type']);
- }
- return $ret;
- }
- public function vaccines()
- {
- return $this->belongsToMany(Vaccines::class,'vaccines_id');
- }
- public function user()
- {
- return $this->hasOne(CdmsUsers::class,'org_id','id');
- }
- public function communityNotice()
- {
- return $this->hasOne(CommunityNotice::class, 'organization_id', 'id');
- }
- public function offices(){
- return $this->hasMany(Office::class,'org_id','id');
- }
- public function docterOrganization()
- {
- return $this->hasMany(DocterOrganization::class)->where('state', 1)->where('authentication_end_time', '>', time());
- }
- public function getCanVaccineDaysAttribute()
- {
- $show_days = DocterSetting::where('org_id', $this->id)->where('type', 2)->value('show_days');
- return !empty($show_days) ? $show_days : 0;
- }
- public function getCanNurseDaysAttribute()
- {
- $show_days = DocterSetting::where('org_id', $this->id)->where('type', 3)->value('show_days');
- return !empty($show_days) ? $show_days : 0;
- }
- }
|