2018-10-12 14:52:08 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace common\models;
|
|
|
|
|
|
|
|
use Yii;
|
2023-04-12 13:14:37 +03:00
|
|
|
use yii\helpers\ArrayHelper;
|
2018-10-12 14:52:08 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the model class for table "position".
|
|
|
|
*
|
|
|
|
* @property int $id
|
|
|
|
* @property string $name
|
|
|
|
*/
|
|
|
|
class Position extends \yii\db\ActiveRecord
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public static function tableName()
|
|
|
|
{
|
|
|
|
return 'position';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[['name'], 'required'],
|
|
|
|
[['name'], 'string', 'max' => 100],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function attributeLabels()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'id' => 'ID',
|
|
|
|
'name' => 'Название',
|
|
|
|
];
|
|
|
|
}
|
2022-03-17 14:50:57 +03:00
|
|
|
|
|
|
|
public function getUserCard(): \yii\db\ActiveQuery
|
|
|
|
{
|
|
|
|
return $this->hasMany(UserCard::class, ['position_id' => 'id']);
|
|
|
|
}
|
2023-04-12 13:14:37 +03:00
|
|
|
|
|
|
|
public static function getList()
|
|
|
|
{
|
|
|
|
return ArrayHelper::map(self::find()->all(), 'id', 'name');
|
|
|
|
}
|
2018-10-12 14:52:08 +03:00
|
|
|
}
|