php - 如何在 Symfony 4 中隐藏模型/实体中的特定列
问题描述
id, firstname, lastname and password
我在 Symfony 4 Doctrine orm 中有基本字段的用户实体。使用方法隐藏密码字段的最简单方法是什么find()
?例如在 Laravel 模型中,我们可以这样做
class User extends Model {
protected $hidden = ['password']
...
select()
没有编辑我找不到合适的解决方案。谢谢
解决方案
Laravel 仍然有一个更简单的方法来处理 Json 和序列化,这要归功于它的 EloquentCollections ...etc
但在 Symfony(4 及更高版本)中,您可以使用@Ignore()
注释忽略字段。
更多细节在这里:忽略字段
希望你觉得它有帮助。
推荐阅读
- realex-payments-api - 全球支付 HPP 沙箱。使用 ngrok 时 MERCHANT_RESPONSE_URL 中的 508 个无效字符
- python-3.x - Python Pandas用动态名称修剪列的空白
- python - 简单非线性回归的 Keras 预测
- javascript - Moment.js - 如何获取用户时区?
- sql - SQL更新(案例)多个值
- python - 使用 joblib 保存的模型给出不同的分数
- gps - 来自两点边界的 Mapbox 矩形线
- html - 输入中数字之间的空间自动
- python - 如何在这个 Python 模因制作器中添加笔画?
- reactjs - React Hooks 无法更新状态