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

34 lines
899 B
PHP

<?php
namespace common\models\oldDb;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
class Department extends \common\modelsgii\oldDb\Department
{
public function behaviors()
{
return [
[
'class'=>TimestampBehavior::class,
'attributes'=>[
ActiveRecord::EVENT_BEFORE_INSERT=>['created_at','updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE=>['updated_at'],
]
]
];
}
public function getChild()
{
return $this->hasMany(Department::class,['pid'=>'id']);
}
//科室
public function getDepart(){
//一个门店对应多个科室,一个科室对应多个门店
return $this->hasMany(Store::class, ['id' => 'store_id'])
->viaTable(StoreDepartment::tableName(), ['depart_id' => 'id']);
}
}