Files
xk-api-yii/common/models/UserPatientCase.php
2024-09-19 11:32:39 +08:00

33 lines
927 B
PHP

<?php
namespace common\models;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
class UserPatientCase extends \common\modelsgii\UserPatientCase
{
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
],
],
];
}
public function afterFind()
{
parent::afterFind();
isset($this->created_at) && $this->created_at = date('Y-m-d H:i:s', $this->created_at);
isset($this->updated_at) && $this->updated_at = date('Y-m-d H:i:s', $this->updated_at);
}
public function getUserPatient()
{
return $this->hasMany(UserPatient::className(),['id'=>'user_patient_id']);
}
}