changes in manager and manager_employee, replaced user_id to card_id

This commit is contained in:
iIronside
2021-12-23 11:28:27 +03:00
parent ce25dc44ea
commit ac4e5d62ec
22 changed files with 2570 additions and 71 deletions

View File

@ -9,9 +9,9 @@ use yii\db\ActiveQuery;
* This is the model class for table "manager".
*
* @property int $id
* @property int $user_id
* @property int $user_card_id
*
* @property User $user
* @property UserCard $userCard
* @property ManagerEmployee[] $managerEmployees
*/
class Manager extends \yii\db\ActiveRecord
@ -30,8 +30,10 @@ class Manager extends \yii\db\ActiveRecord
public function rules()
{
return [
[['user_id'], 'integer'],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
[['user_card_id'], 'integer'],
[['user_card_id'], 'required'],
['user_card_id', 'unique', 'message'=>'Уже является менеджером'],
[['user_card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_card_id' => 'id']],
];
}
@ -42,7 +44,7 @@ class Manager extends \yii\db\ActiveRecord
{
return [
'id' => 'ID',
'user_id' => 'Пользователь',
'user_card_id' => 'Карточка менеджера',
];
}
@ -57,9 +59,9 @@ class Manager extends \yii\db\ActiveRecord
/**
* @return ActiveQuery
*/
public function getUser()
public function getUserCard()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']);
}
/**