我有 User 模型,它与 Post 模型有 HasMany 关系。当我在 Nova 的用户资源中包含 HasMany 的字段时,我看到有 Create post
button .如何删除/隐藏该按钮?
最佳答案
您可以使用 Policies
实现此目的.
根据文档:
If a policy exists but is missing a method for a particular action, the user will not be allowed to perform that action. So, if you have defined a policy, don't forget to define all of its relevant authorization methods.
因此,在您的情况下,如果您想完全隐藏按钮,只需为您的资源创建一个策略 (PostPolicy
) 而不要实现 create
方法。
关于php - Laravel Nova - 如何从 HasMany 字段中隐藏 'Create' 按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55555786/