64 lines
1.2 KiB
PHP
64 lines
1.2 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace common\models;
|
||
|
|
||
|
use Yii;
|
||
|
|
||
|
/**
|
||
|
* This is the model class for table "manager".
|
||
|
*
|
||
|
* @property int $id
|
||
|
* @property int $user_id
|
||
|
*
|
||
|
* @property User $user
|
||
|
* @property ManagerEmployee[] $managerEmployees
|
||
|
*/
|
||
|
class Manager extends \yii\db\ActiveRecord
|
||
|
{
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public static function tableName()
|
||
|
{
|
||
|
return 'manager';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function rules()
|
||
|
{
|
||
|
return [
|
||
|
[['user_id'], 'integer'],
|
||
|
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function attributeLabels()
|
||
|
{
|
||
|
return [
|
||
|
'id' => 'ID',
|
||
|
'user_id' => 'Менеджер',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return \yii\db\ActiveQuery
|
||
|
*/
|
||
|
public function getUser()
|
||
|
{
|
||
|
return $this->hasOne(User::className(), ['id' => 'user_id']);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return \yii\db\ActiveQuery
|
||
|
*/
|
||
|
public function getManagerEmployees()
|
||
|
{
|
||
|
return $this->hasMany(ManagerEmployee::className(), ['manager_id' => 'id']);
|
||
|
}
|
||
|
}
|