如何在 Laravel Nova 中显示表情符号

问题描述

在 Laravel Nova 中,我尝试使用其十进制值将用户反馈表情符号保存在数据库中,然后将其显示在仪表板中。

但只显示十进制值而不显示表情符号图标。

例如。 ?、?、?

这在 Nova 中可行吗?还是需要使用第三方库?

这是我的代码

public function fields(Request $request) {
  return [
    Text::make('Name','name')->sortable(),Text::make('Icon','icon')->sortable(),];
}

编辑: 我正在数据库中保存实际字符。我想通了 & 更改为 &

enter image description here

enter image description here

enter image description here

解决方法

我已经找到了问题的答案。

使用 php html_entity_decode() 解决了我的问题。

public function fields(Request $request) {
  return [
    Text::make('Name','name')->sortable(),Text::make('Icon',function() {
      return html_entity_decode($this->icon);
    })->sortable(),];
}

enter image description here