You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
909 B

9 years ago
<?php
namespace tests\models;
use lhs\Yii2SaveRelationsBehavior\SaveRelationsBehavior;
9 years ago
class User extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'user';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'saveRelations' => [
'class' => SaveRelationsBehavior::className(),
'relations' => ['userProfile']
],
];
}
/**
* @inheritdoc
*/
9 years ago
public function rules()
{
return [
['username', 'required'],
['username', 'unique', 'targetClass' => '\tests\models\User'],
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUserProfile()
{
return $this->hasOne(UserProfile::className(), ['user_id' => 'id']);
}
9 years ago
}