5

I have a laravel nova app. Like other nova app on resource list it shows a checkbox before every rows. and a option of select all.

Here is the screenshot of those checkboxes

I want to remove those checkboxes from the resource list.

Thanks.

Paolo Mossini
  • 1,064
  • 2
  • 15
  • 23

1 Answers1

3

As described in comments above, the cleanest way will be limiting user permissions. Otherwise, there are some hacky ways to try:

1. Empty actions

If you resource has no actions, then in your resource file override availableActions method:

/**
 * 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. Hiding with css.

Put this in custom tool, or override layout.blade.php.

EDIT Found a better way of hiding with css thanks to @Max's comment

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. Custom resource-index component.

Create custom tool and override /nova/resources/js/views/Index.vue. This is where checkbox showing logic goes on.

/**
 * Determine whether to show the selection checkboxes for resources
 */
shouldShowCheckBoxes() {
  return (
    Boolean(this.hasResources && !this.viaHasOne) &&
    Boolean(
      this.actionsAreAvailable ||
        this.authorizedToDeleteAnyResources ||
        this.canShowDeleteMenu
    )
  )
},
mervasdayi
  • 729
  • 6
  • 16
  • But have another qus how to precise it for specific resource .? suppose i have a user and post resource i only want the feature at the user resource so that all user can't be deleted at once.. but still want the delete all feature at post resource .... – tanvirofficials Mar 17 '20 at 05:15
  • @tanvirofficials updated my answer in "Hiding with css" section. Just change resource name in my case "products" – mervasdayi Mar 17 '20 at 15:30