34 lines
887 B
PHP
34 lines
887 B
PHP
<?php
|
|
|
|
namespace common\models;
|
|
|
|
use yii\behaviors\TimestampBehavior;
|
|
use yii\db\ActiveRecord;
|
|
|
|
class Department extends \common\modelsgii\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']);
|
|
}
|
|
} |