33 lines
886 B
PHP
33 lines
886 B
PHP
<?php
|
|
|
|
namespace common\models\oldDb;
|
|
|
|
use common\models\HospitalDepartment;
|
|
use yii\behaviors\TimestampBehavior;
|
|
use yii\db\ActiveRecord;
|
|
|
|
class HospitalYard extends \common\modelsgii\oldDb\HospitalYard
|
|
{
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
[
|
|
'class' => TimestampBehavior::class,
|
|
'attributes' => [
|
|
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'],
|
|
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
|
|
],
|
|
],
|
|
];
|
|
}
|
|
|
|
|
|
/**
|
|
* 科室
|
|
*/
|
|
public function getDepartments(){
|
|
//一个院区对应多个科室,一个科室对应多个院区
|
|
return $this->hasMany(HospitalDepartment::class, ['id' => 'depart_id'])
|
|
->viaTable(HospitalYardDepartment::tableName(), ['yard_id' => 'id']);
|
|
}
|
|
} |