初始化仓库
This commit is contained in:
34
common/models/Department.php
Normal file
34
common/models/Department.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user