almirhodzic/nova-toggle
almirhodzic/nova-toggle is a Laravel Nova field that adds a clean toggle switch for boolean attributes, letting you flip values directly from the resource index or detail view. Ideal for managing active/inactive or yes/no flags without leaving the resource list.
Install or upgrade with Composer:
composer require almirhodzic/nova-toggle-5
# or, for existing installs
composer update almirhodzic/nova-toggle-5
This package provides an inline toggle endpoint/field for Laravel Nova 5 boolean attributes. Start by adding the package’s toggle field to a Nova resource for a boolean column, for example an active or published flag. Then confirm two things before relying on it:
The first practical use case is an index-table toggle: let admins flip a boolean directly from a Nova resource index or lens without opening the detail page. If your resource uses SoftDeletes, v1.3.1 is the first release where toggling works correctly from “With Trashed” views and lenses that surface trashed rows.
Inline boolean toggles in Nova resources. Add the package field to resources where a boolean represents a simple state change: active/inactive, featured/unfeatured, published/unpublished. This is best for low-risk flags that do not require additional form input or validation.
Whitelist only intentional attributes. The package enforces a toggleable-attribute whitelist. Treat that list as a security boundary: only expose columns that are safe to flip from an index view. Avoid wildcard or broad whitelists.
Authorize through policies/gates. The toggle endpoint applies authorization checks before changing the record. Implement a policy method or gate for the toggle action, and remember that the check applies to trashed records as well in v1.3.1.
Soft-delete-aware lenses and “With Trashed” views. If a lens or resource index includes trashed rows via withTrashed(), the package now resolves the record with withTrashed() when the Nova resource uses soft deletes. This means toggles from those views should work without custom route binding or manual lookup logic.
Use model events/observers for side effects. The toggle endpoint updates the attribute directly. If a toggle should send notifications, write audit logs, or invalidate caches, attach that behavior to model events or observers rather than duplicating endpoint logic.
Pair with Nova actions for complex transitions. Use the toggle for simple state flips. If changing the flag requires confirmation, validation, a reason, or a multi-step workflow, use a Nova action or detail form instead.
withTrashed() lookup added in v1.3.1. Upgrade first before writing custom route-binding workarounds.withTrashed() for soft-delete resources, but custom global scopes or custom route model binding may still affect record resolution. Test toggles from the exact lens/index view your users rely on.How can I help you explore Laravel packages today?