Laravel Nova:如何在更新资源时隐藏字段

问题描述 投票:0回答:1

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

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

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

canSeeWhen('viewProfile', $this);

但是这些方法适用于所有情况,例如,如果我在字段上定义canSee方法,则在索引,细节,创建和更新页面上看不到该字段。

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

我怎样才能做到这一点?

laravel-nova laravel-authorization
1个回答
2
投票

我知道了。你可以使用hideWhenUpdating方法。

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

其他方法是:

hideFromIndex
hideFromDetail
hideWhenCreating
hideWhenUpdating
onlyOnIndex
onlyOnDetail
onlyOnForms
exceptOnForms
© www.soinside.com 2019 - 2024. All rights reserved.