我有一个laravel nova应用。与资源列表上的其他nova应用程序一样,它在每行之前显示一个复选框。以及全选的选项。
我想从资源列表中删除那些复选框。
谢谢。
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
.table td:first-child, .table th:first-child,.v-popover.-mx-2 {
display: none;
}
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
)
)
},