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

33 lines
916 B
PHP
Raw Normal View History

2024-09-19 11:32:39 +08:00
<?php
2024-12-19 19:20:27 +08:00
namespace common\models\oldDb;
2024-09-19 11:32:39 +08:00
2024-12-19 19:20:27 +08:00
use common\models\HospitalDepartment;
2024-09-19 11:32:39 +08:00
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
2024-12-19 19:20:27 +08:00
class Hospital extends \common\modelsgii\oldDb\Hospital
2024-09-19 11:32:39 +08:00
{
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']);
}
}