show->field($field, $label); } /** * 显示用户名 * * 复用价值:高 - 在多个控制器中使用,提供统一的用户名显示 * * @param string $field 字段名 * @param string $label 标签名 * @return Show\Field */ public function fieldUsername(string $field = 'username', string $label = '用户名'): Show\Field { return $this->show->field($field, $label); } /** * 显示用户状态 * * 复用价值:高 - 统一处理用户状态的显示,使用枚举类型 * * @param string $field 字段名 * @param string $label 标签名 * @return Show\Field */ public function fieldStatus(string $field = 'status2', string $label = '状态'): Show\Field { return $this->show->field($field, $label)->as(function ($value) { return STATUS2::getName($value); }); } /** * 显示用户头像 * * 复用价值:高 - 统一处理用户头像的显示 * * @param string $field 字段名 * @param string $label 标签名 * @return Show\Field */ public function fieldAvatar(string $field = 'avatar', string $label = '头像'): Show\Field { return $this->show->field($field, $label)->image(); } /** * 显示用户安全密码 * * 复用价值:高 - 统一处理用户安全密码的显示,隐藏实际密码 * * @param string $field 字段名 * @param string $label 标签名 * @return Show\Field */ public function fieldSecretPassword(string $field = 'secret_password', string $label = '安全密码'): Show\Field { return $this->show->field($field, $label)->as(function ($value) { return $value ? '已设置' : '未设置'; }); } /** * 添加用户基本信息面板 * * 复用价值:高 - 提供完整的用户基本信息面板 * * @return void */ public function addUserBasicPanel(): void { $this->show->divider('基本信息'); $this->fieldUserId(); $this->fieldUsername(); $this->show->field('nickname', '昵称'); $this->fieldAvatar(); $this->fieldStatus(); } /** * 添加用户联系信息面板 * * 复用价值:高 - 提供完整的用户联系信息面板 * * @return void */ public function addUserContactPanel(): void { $this->show->divider('联系信息'); $this->show->field('phone', '手机号'); $this->show->field('email', '邮箱'); $this->show->field('wx_id', '微信号'); } /** * 添加用户安全信息面板 * * 复用价值:高 - 提供完整的用户安全信息面板 * * @return void */ public function addUserSecurityPanel(): void { $this->show->divider('安全信息'); $this->fieldSecretPassword(); $this->show->field('last_check_at', '最后验证时间'); } /** * 添加用户时间信息面板 * * 复用价值:高 - 提供完整的用户时间信息面板 * * @return void */ public function addUserTimePanel(): void { $this->show->divider('时间信息'); $this->show->field('created_at', '创建时间'); $this->show->field('updated_at', '更新时间'); $this->show->field('deleted_at', '删除时间'); } }