【问题标题】:Laravel Nova: How to hide fields only when updating the resourceLaravel Nova:如何仅在更新资源时隐藏字段
【发布时间】:2019-07-20 22:34:18
【问题描述】:

我知道我可以使用canSee 方法隐藏一些字段:

Text::make('Something')
    ->canSee(function ($request) {
        return $request->user()->can('some ability');
    }),

documentation 开始,有一个canSeeWhen 方法可以根据用户的能力隐藏字段:

canSeeWhen('viewProfile', $this);

但这些方法适用于所有情况,例如,如果我在字段上定义 canSee 方法,则该字段在索引、详细信息、创建和更新页面上是不可见的。

我想在用户编辑资源时隐藏一些字段。

我该怎么做?

【问题讨论】:

    标签: laravel-nova laravel-authorization


    【解决方案1】:

    我明白了。您可以使用hideWhenUpdating 方法。

    Text::make('Something')->hideWhenUpdating();
    

    其他方法有:

    hideFromIndex
    hideFromDetail
    hideWhenCreating
    hideWhenUpdating
    onlyOnIndex
    onlyOnDetail
    onlyOnForms
    exceptOnForms
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-11
      • 2019-12-08
      • 2020-07-24
      • 2019-08-28
      • 2023-03-19
      • 1970-01-01
      • 2020-05-21
      相关资源
      最近更新 更多