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.
28 lines
909 B
28 lines
909 B
<?php
|
|
|
|
namespace App\Admin\Transforms; // 定义命名空间
|
|
|
|
use App\Enums\UserStatusEnum; // 引入用户状态枚举类(未使用)
|
|
|
|
/**
|
|
* 是/否转换类
|
|
*
|
|
* 该类用于将布尔值转换为相应的图标表示形式。
|
|
*/
|
|
class YesNoTransform implements Transform
|
|
{
|
|
/**
|
|
* 将布尔值转换为对应的图标表示
|
|
*
|
|
* @param bool $is 布尔值,用于表示是或否
|
|
* @return string 返回相应的 HTML 图标字符串
|
|
*/
|
|
public static function trans($is)
|
|
{
|
|
// 返回对应的图标,绿色勾表示“是”,红色叉表示“否”
|
|
return $is
|
|
? "<i style='color: green;' class=\"fa fa-check-circle\" aria-hidden=\"true\"></i>" // 当 $is 为 true 时,返回绿色勾图标
|
|
: "<i style='color: red;' class=\"fa fa-times\" aria-hidden=\"true\"></i>"; // 当 $is 为 false 时,返回红色叉图标
|
|
}
|
|
}
|