Files
xk-api-yii/common/models/oldDb/Hospital.php

33 lines
916 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace common\models\oldDb;
use common\models\HospitalDepartment;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
class Hospital extends \common\modelsgii\oldDb\Hospital
{
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
],
],
];
}
//院区列表
public function getYard(){
// 一个医院对应多个院区一对多的关系使用hasMany()关联
return $this->hasMany(HospitalYard::class,['hospital_id'=>'id']);
}
public function getDepartment()
{
return $this->hasOne(HospitalDepartment::className(),['department_id'=>'id']);
}
}