初始化仓库
This commit is contained in:
59
common/models/User.php
Normal file
59
common/models/User.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace common\models;
|
||||
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
class User extends \common\modelsgii\User
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => TimestampBehavior::class,
|
||||
'attributes' => [
|
||||
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'],
|
||||
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 可覆盖 fields() 方法来增加、删除、重命名、重定义字段
|
||||
*/
|
||||
public function fields()
|
||||
{
|
||||
$fields = parent::fields();
|
||||
// 删除一些包含敏感信息的字段
|
||||
unset($fields['session_key']);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
// 关联评论
|
||||
public function getComment(){
|
||||
return $this->hasMany(UserComment::className(),['u_id'=>'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 亲属
|
||||
*/
|
||||
public function getAllRelative(){
|
||||
return $this->hasMany(UserRelative::className(),['u_id'=>'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收货地址
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->hasMany(Address::className(),['user_id'=>'id']);
|
||||
}
|
||||
/**
|
||||
* 收货地址
|
||||
*/
|
||||
public function getUserPatient()
|
||||
{
|
||||
return $this->hasMany(UserPatient::className(),['user_id'=>'id']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user