99 lines
2.6 KiB
PHP
99 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace common\models;
|
|
|
|
use Yii;
|
|
use yii\behaviors\TimestampBehavior;
|
|
use yii\helpers\ArrayHelper;
|
|
|
|
/**
|
|
* This is the model class for table "mobile_device".
|
|
*
|
|
* @property integer $id
|
|
* @property integer $id_card
|
|
* @property string $status
|
|
* @property string $device_identifier
|
|
* @property string $device_name
|
|
* @property string $activated_at
|
|
* @property string $created_at
|
|
* @property string $updated_at
|
|
*/
|
|
class MobileDevice extends \yii\db\ActiveRecord
|
|
{
|
|
|
|
const STATUS_ACTIVE = 'active';
|
|
const STATUS_INACTIVE = 'inactive';
|
|
const STATUS_DELETED_MANUAL = 'deleted_manual';
|
|
const STATUS_DELETED_SYSTEM = 'deleted_system';
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return 'mobile_device';
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
// [['id_card'], 'integer'],
|
|
// [['activated_at', 'created_at', 'updated_at'], 'safe'],
|
|
// [['created_at', 'updated_at'], 'required'],
|
|
// [['status'], 'string', 'max' => 20],
|
|
// [['device_identifier'], 'string', 'max' => 255]
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'id' => Yii::t('common/mobiledevice', 'ID'),
|
|
'id_card' => Yii::t('common/mobiledevice', 'Id Card'),
|
|
'status' => Yii::t('common/mobiledevice', 'Status'),
|
|
'device_identifier' => Yii::t('common/mobiledevice', 'Device Identifier'),
|
|
'device_name' => Yii::t('common/mobiledevice', 'Device Name'),
|
|
'activated_at' => Yii::t('common/mobiledevice', 'Activated At'),
|
|
'created_at' => Yii::t('common/mobiledevice', 'Created At'),
|
|
'updated_at' => Yii::t('common/mobiledevice', 'Updated At'),
|
|
];
|
|
}
|
|
|
|
public function behaviors()
|
|
{
|
|
return ArrayHelper::merge( [
|
|
[
|
|
'class' => TimestampBehavior::className(),
|
|
'value' => function(){ return date('Y-m-d H:i:s' ); }
|
|
]
|
|
],
|
|
parent::behaviors());
|
|
}
|
|
|
|
public static function toStatusHumanReadable($status){
|
|
$result = "";
|
|
switch ($status){
|
|
case self::STATUS_ACTIVE:
|
|
$result ='Aktív';
|
|
break;
|
|
case self::STATUS_DELETED_MANUAL:
|
|
$result ='Törölve (m)';
|
|
break;
|
|
case self::STATUS_DELETED_SYSTEM:
|
|
$result ='Törölve (r)';
|
|
break;
|
|
case self::STATUS_INACTIVE:
|
|
$result ='Inaktív';
|
|
break;
|
|
|
|
}
|
|
return $result;
|
|
}
|
|
}
|