初始化仓库
This commit is contained in:
42
common/models/UserComment.php
Normal file
42
common/models/UserComment.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
class UserComment extends \common\modelsgii\UserComment
|
||||
{
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => TimestampBehavior::class,
|
||||
'attributes' => [
|
||||
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'],
|
||||
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
// 关联用户
|
||||
public function getUser()
|
||||
{
|
||||
return $this->hasOne(User::className(),['id'=>'user_id']);
|
||||
}
|
||||
|
||||
// 关联患者
|
||||
public function getUserPatient()
|
||||
{
|
||||
return $this->hasOne(UserPatient::className(),['id'=>'u_id']);
|
||||
}
|
||||
|
||||
public function afterFind()
|
||||
{
|
||||
parent::afterFind();
|
||||
isset($this->created_at) && $this->created_at = date('Y-m-d', $this->created_at);
|
||||
isset($this->updated_at) && $this->updated_at = date('Y-m-d', $this->updated_at);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user