我知道我可以用canSee
方法隐藏一些字段:
Text::make('Something')
->canSee(function ($request) {
return $request->user()->can('some ability');
}),
从documentation,有一个canSeeWhen
方法,你可以根据用户的能力隐藏字段:
canSeeWhen('viewProfile', $this);
但是这些方法适用于所有情况,例如,如果我在字段上定义canSee
方法,则在索引,细节,创建和更新页面上看不到该字段。
我想在用户编辑资源时专门隐藏一些字段。
我怎样才能做到这一点?
我知道了。你可以使用hideWhenUpdating
方法。
Text::make('Something')->hideWhenUpdating();
其他方法是:
hideFromIndex
hideFromDetail
hideWhenCreating
hideWhenUpdating
onlyOnIndex
onlyOnDetail
onlyOnForms
exceptOnForms