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

32 lines
866 B
PHP
Raw Normal View History

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