You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1004 B
42 lines
1004 B
7 years ago
|
<?php
|
||
|
|
||
|
namespace core\helpers;
|
||
|
|
||
|
use core\entities\user\User;
|
||
|
use yii\helpers\ArrayHelper;
|
||
|
use yii\helpers\Html;
|
||
|
use Yii;
|
||
|
|
||
|
class UserHelper
|
||
|
{
|
||
|
public static function statusList(): array
|
||
|
{
|
||
|
return [
|
||
|
User::STATUS_WAIT => Yii::t('user', 'Wait'),
|
||
|
User::STATUS_ACTIVE => Yii::t('user', 'Active'),
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public static function statusName($status): string
|
||
|
{
|
||
|
return ArrayHelper::getValue(self::statusList(), $status);
|
||
|
}
|
||
|
|
||
|
public static function statusLabel($status): string
|
||
|
{
|
||
|
switch ($status) {
|
||
|
case User::STATUS_WAIT:
|
||
|
$class = 'label label-default';
|
||
|
break;
|
||
|
case User::STATUS_ACTIVE:
|
||
|
$class = 'label label-success';
|
||
|
break;
|
||
|
default:
|
||
|
$class = 'label label-default';
|
||
|
}
|
||
|
|
||
|
return Html::tag('span', ArrayHelper::getValue(self::statusList(), $status), [
|
||
|
'class' => $class,
|
||
|
]);
|
||
|
}
|
||
|
}
|