new-support.webeffector.ru/common/components/schema/models/Schema.php

69 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2024-07-04 06:42:20 +03:00
<?php
namespace common\components\schema\models;
use Yii;
use yii\db\ActiveRecord;
use common\helpers\TextHelper;
use yii\behaviors\TimestampBehavior;
/**
* This is the model class for table "{{%schema}}".
*
* @property int $id
* @property string|null $name
* @property int|null $created_at
* @property int|null $updated_at
*
* @property-read int|null|array $typeList
*/
class Schema extends ActiveRecord
{
const TYPE_ACCURATE = 1; // точное exact
const TYPE_SOFT = 2; // разбавочое dilute
public static function tableName(): string
{
return '{{%bad_word}}';
}
public function rules(): array
{
return [
[['created_at', 'updated_at'], 'integer'],
[['name'], 'string', 'max' => 255],
];
}
public function attributeLabels(): array
{
return [
'id' => Yii::t('schema', 'ID'),
'name' => Yii::t('schema', 'Название'),
'created_at' => Yii::t('schema', 'Создано'),
'updated_at' => Yii::t('schema', 'Изменено'),
];
}
public function behaviors(): array
{
return [
TimestampBehavior::class,
];
}
public static function getTypeList($type = null)
{
$typeList = [
self::TYPE_ACCURATE => Yii::t('schema', 'Точное'),
self::TYPE_SOFT => Yii::t('schema', 'Разбавочное'),
];
if ($type) {
return isset($typeList[$type]) ? $typeList[$type] : null;
}
return $typeList;
}
}