TimestampBehavior::class, 'attributes'=>[ ActiveRecord::EVENT_BEFORE_INSERT=>['created_at','updated_at'], ActiveRecord::EVENT_BEFORE_UPDATE=>['updated_at'], ] ] ]; } //轮播图 public function getNav(){ return $this->hasMany(Nav::class, ['store_id' => 'id'])->andWhere(['is_delete' => 0])->orderBy('sort ASC,id ASC'); } //科室 public function getDepartments(){ //一个门店对应多个科室,一个科室对应多个门店 return $this->hasMany(Department::class, ['id' => 'depart_id']) ->viaTable(StoreDepartment::tableName(), ['store_id' => 'id']); } //关联仓库 public function getDrugStore() { return $this->hasOne(DrugStore::class, ['id' => 'drugstore_id']); } public function getChild() { return $this->hasMany(Department::class,['pid'=>'id']); } public function getReconciliation() { return $this->hasMany(Reconciliation::class,['store_id'=>'id']); } public function getAdmin() { return $this->hasOne(Admin::class,['uid'=>'uid']); } public function getProvince() { return $this->hasOne(Region::class,['id'=>'province_id']); } public function getCity() { return $this->hasOne(Region::class,['id'=>'city_id']); } }