mirror of
https://github.com/janickiy/yii2-nomer
synced 2025-03-09 15:39:59 +00:00
add files to project
This commit is contained in:
commit
5cac498444
3729 changed files with 836998 additions and 0 deletions
77
models/Token.php
Normal file
77
models/Token.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
* @property integer $id
|
||||
* @property integer $type
|
||||
* @property integer $server_id
|
||||
* @property string $token
|
||||
* @property integer $status
|
||||
* @property string $tm_ban
|
||||
*/
|
||||
class Token extends ActiveRecord
|
||||
{
|
||||
const TYPE_TRUECALLER = 1;
|
||||
|
||||
const STATUS_INACTIVE = 0;
|
||||
const STATUS_ACTIVE = 1;
|
||||
|
||||
public static function getTypeName($type) {
|
||||
switch ($type) {
|
||||
case self::TYPE_TRUECALLER: return 'Truecaller';
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getTypes()
|
||||
{
|
||||
return [
|
||||
self::TYPE_TRUECALLER => self::getTypeName(self::TYPE_TRUECALLER)
|
||||
];
|
||||
}
|
||||
|
||||
public static function getStatusName($status) {
|
||||
switch ($status) {
|
||||
case self::STATUS_INACTIVE: return 'Неактивный';
|
||||
case self::STATUS_ACTIVE: return 'Активный';
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'tokens';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['type', 'token'], 'required'],
|
||||
['server_id', 'integer'],
|
||||
['server_id', 'default', 'value' => 0],
|
||||
['status', 'in', 'range' => array_keys(self::getTypes())],
|
||||
['tm_ban', 'safe']
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'type' => 'Тип',
|
||||
'server_id' => 'Сервер',
|
||||
'token' => 'Токен',
|
||||
'status' => 'Статус',
|
||||
'tm_ban' => 'Время блокировки'
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue