add employee module
This commit is contained in:
67
common/models/ManagerEmployee.php
Normal file
67
common/models/ManagerEmployee.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use yii\db\ActiveQuery;
|
||||
|
||||
/**
|
||||
* This is the model class for table "manager_employee".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $manager_id
|
||||
* @property int $employee_id
|
||||
*
|
||||
* @property User $user
|
||||
* @property Manager $manager
|
||||
*/
|
||||
class ManagerEmployee extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'manager_employee';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['manager_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'manager_id' => 'Менеджер',
|
||||
'employee_id' => 'Работник',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->hasOne(User::className(), ['id' => 'employee_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getManager()
|
||||
{
|
||||
return $this->hasOne(Manager::className(), ['id' => 'manager_id']);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user