changes in manager and manager_employee, replaced user_id to card_id
This commit is contained in:
@ -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']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,10 +9,10 @@ use yii\db\ActiveQuery;
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $manager_id
|
||||
* @property int $employee_id
|
||||
* @property int $user_card_id
|
||||
*
|
||||
* @property User $user
|
||||
* @property Manager $manager
|
||||
* @property UserCard $userCard
|
||||
*/
|
||||
class ManagerEmployee extends \yii\db\ActiveRecord
|
||||
{
|
||||
@ -30,9 +30,10 @@ class ManagerEmployee extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['manager_id', 'employee_id'], 'required'],
|
||||
[['manager_id', 'employee_id'], 'integer'],
|
||||
[['employee_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['employee_id' => 'id']],
|
||||
[['manager_id', 'user_card_id'], 'required'],
|
||||
[['manager_id'], 'integer'],
|
||||
['user_card_id', 'unique', 'targetAttribute' => ['manager_id', 'user_card_id'], 'message'=>'Этот сотрудник уже закреплён за менеджером'],
|
||||
[['user_card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_card_id' => 'id']],
|
||||
[['manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['manager_id' => 'id']],
|
||||
];
|
||||
}
|
||||
@ -45,16 +46,16 @@ class ManagerEmployee extends \yii\db\ActiveRecord
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'manager_id' => 'Менеджер',
|
||||
'employee_id' => 'Работник',
|
||||
'user_card_id' => 'Карточка работника',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getUser()
|
||||
public function getUserCard(): ActiveQuery
|
||||
{
|
||||
return $this->hasOne(User::className(), ['id' => 'employee_id']);
|
||||
return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -221,15 +221,15 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
return $this->hasOne(UserCard::class, ['id_user' => 'id']);
|
||||
}
|
||||
|
||||
public function getManager()
|
||||
{
|
||||
return $this->hasOne(Manager::class, ['user_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getManagerEmployee()
|
||||
{
|
||||
return $this->hasMany(ManagerEmployee::className(), ['employee_id' => 'id']);
|
||||
}
|
||||
// public function getManager()
|
||||
// {
|
||||
// return $this->hasOne(Manager::class, ['user_id' => 'id']);
|
||||
// }
|
||||
//
|
||||
// public function getManagerEmployee()
|
||||
// {
|
||||
// return $this->hasMany(ManagerEmployee::className(), ['employee_id' => 'id']);
|
||||
// }
|
||||
|
||||
public function getProjectUser()
|
||||
{
|
||||
|
@ -220,6 +220,11 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
return ArrayHelper::map(self::find()->all(), 'id', 'fio');
|
||||
}
|
||||
|
||||
public function getManager()
|
||||
{
|
||||
return $this->hasOne(Manager::class, ['user_card_id' => 'id']);
|
||||
}
|
||||
|
||||
public static function generateUserForUserCard($card_id = null)
|
||||
{
|
||||
$userCardQuery = self::find();
|
||||
|
Reference in New Issue
Block a user