33 lines
916 B
PHP
33 lines
916 B
PHP
<?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']);
|
||
}
|
||
} |