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

42 lines
1.0 KiB
PHP

<?php
namespace common\models\oldDb;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
class UserComment extends \common\modelsgii\oldDb\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);
}
}