Files
xk-api-yii/common/models/Hospital.php
2024-09-19 11:32:39 +08:00

32 lines
866 B
PHP
Raw 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;
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']);
}
}