如何从 laravel nova 的资源列表中删除所有复选框?
how to remove all checkboxes from resource list in laravel nova?
我有一个 laravel nova 应用程序。与资源列表上的其他 nova 应用程序一样,它在每一行之前显示一个复选框。以及 select 全部的选项。
我想从资源列表中删除那些复选框。
谢谢。
如上面的评论所述,最简洁的方法是限制用户权限。否则,有一些 hacky 方法可以尝试:
1.空动作
如果您的资源没有任何操作,则在您的资源文件中覆盖 availableActions
方法:
/**
* Get the actions that are available for the given request.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return \Illuminate\Support\Collection
*/
public function availableActions(NovaRequest $request)
{
return [];
}
2。隐藏 css.
将其放入自定义工具中,或覆盖 layout.blade.php
。
编辑 多亏
找到了更好的隐藏方法 css
div[dusk="products-index-component"] div[dusk="select-all-dropdown"],
div[dusk="products-index-component"] .table td:first-child,
div[dusk="products-index-component"] .table th:first-child {
display: none !important;
}
3。自定义 resource-index
组件。
创建自定义工具并覆盖 /nova/resources/js/views/Index.vue
。这是显示逻辑的复选框。
/**
* Determine whether to show the selection checkboxes for resources
*/
shouldShowCheckBoxes() {
return (
Boolean(this.hasResources && !this.viaHasOne) &&
Boolean(
this.actionsAreAvailable ||
this.authorizedToDeleteAnyResources ||
this.canShowDeleteMenu
)
)
},
我有一个 laravel nova 应用程序。与资源列表上的其他 nova 应用程序一样,它在每一行之前显示一个复选框。以及 select 全部的选项。
我想从资源列表中删除那些复选框。
谢谢。
如上面的评论所述,最简洁的方法是限制用户权限。否则,有一些 hacky 方法可以尝试:
1.空动作
如果您的资源没有任何操作,则在您的资源文件中覆盖 availableActions
方法:
/**
* Get the actions that are available for the given request.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return \Illuminate\Support\Collection
*/
public function availableActions(NovaRequest $request)
{
return [];
}
2。隐藏 css.
将其放入自定义工具中,或覆盖 layout.blade.php
。
编辑 多亏
div[dusk="products-index-component"] div[dusk="select-all-dropdown"],
div[dusk="products-index-component"] .table td:first-child,
div[dusk="products-index-component"] .table th:first-child {
display: none !important;
}
3。自定义 resource-index
组件。
创建自定义工具并覆盖 /nova/resources/js/views/Index.vue
。这是显示逻辑的复选框。
/**
* Determine whether to show the selection checkboxes for resources
*/
shouldShowCheckBoxes() {
return (
Boolean(this.hasResources && !this.viaHasOne) &&
Boolean(
this.actionsAreAvailable ||
this.authorizedToDeleteAnyResources ||
this.canShowDeleteMenu
)
)
},