guild/common/models/UseStatus.php

87 lines
1.8 KiB
PHP
Raw Normal View History

2018-10-11 11:15:09 +03:00
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "use_status".
*
* @property int $id
* @property int $status_id
* @property int $use
*
* @property array $statuses
* @property string $statusesText
*
* @property Status $status
*/
class UseStatus extends \yii\db\ActiveRecord
{
const USE_PROFILE = 0;
const USE_PROJECT = 1;
2018-10-11 17:24:47 +03:00
const USE_COMPANY = 2;
2019-06-21 18:05:58 +03:00
const USE_BALANCE = 3;
2019-12-05 15:05:33 +03:00
const USE_NOTE= 4;
2018-10-11 11:15:09 +03:00
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'use_status';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['status_id', 'use'], 'required'],
[['status_id', 'use'], 'integer'],
[['status_id'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'status_id' => 'Статус',
'use' => 'Применение',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getStatus()
{
return $this->hasOne(Status::class, ['id' => 'status_id']);
}
public function getStatuses()
{
return [
self::USE_PROFILE => 'Профиль',
2018-10-11 17:24:47 +03:00
self::USE_PROJECT => 'Проект',
2019-06-21 18:05:58 +03:00
self::USE_COMPANY => 'Компания',
2019-12-05 15:05:33 +03:00
self::USE_BALANCE => 'Баланс',
self::USE_NOTE => 'Заметка'
2018-10-11 11:15:09 +03:00
];
}
/**
* @return string status text label
*/
2019-07-02 16:51:33 +03:00
public static function getStatusesText($id)
2018-10-11 11:15:09 +03:00
{
2019-07-02 16:51:33 +03:00
$model = new self();
return $model->statuses[$id];
2018-10-11 11:15:09 +03:00
}
}