

Overview
Nova actions may be generated using thenova:action Artisan command. By default, all actions are placed in the app/Nova/Actions directory:
--destructive option:
handle method. The handle method receives the values for any fields attached to the action, as well as a collection of selected models. The handle method always receives a Collection of models, even if the action is only being performed against a single model.
Within the handle method, you may perform whatever tasks are necessary to complete the action. You are free to update database records, send emails, call other services, etc. The sky is the limit!
Action Titles
Typically, Nova utilizes the action’s class name to determine the displayable name of the action that should be shown in the action selection menu. If you would like to change the displayable name of the action, you may define aname property on the action class:
Destructive Actions
You may designate an action as destructive or dangerous by defining an action class that extendsLaravel\Nova\Actions\DestructiveAction. This will change the color of the action’s confirm button to red:

When a destructive action is added to a resource that has an associated authorization policy, the policy’s
delete method must return true in order for the action to run.Action Callbacks
The
Action::then method should not be utilized if your action is queued. To achieve similar functionality when using queued actions, you should leverage Nova’s action batching callbacks.then method when registering your action.
The then methods accepts a closure which will be invoked when the action has finished executing against all of the selected resources. The closure will receive a flattened Laravel collection containing the values that were returned by the action.
For example, note that the following action’s handle method returns the $models it receives:
then callback to access the returned models and interact with them after the action has finished executing:
Action Fields
Sometimes you may wish to gather additional information from the user before dispatching an action. For this reason, Nova allows you to attach most of Nova’s supported fields directly to an action. When the action is initiated, Nova will prompt the user to provide input for the fields:
fields method:
handle method, you may access your fields using dynamic accessors on the provided ActionFields instance:
Action Fields Default Values
You may use thedefault method to set the default value for an action field:
Action Responses
Typically, when an action is executed, a generic “success” messages is displayed in the Nova UI. However, you are free to customize this response using a variety of methods available via theActionResponse class. To display a custom “success” message, you may invoke the ActionResponse::message method from your handle method:
ActionResponse::danger method:
Messages passed to
ActionResponse are not escaped before rendering. If you are providing untrusted user data to ActionResponse, ensure that you escape it using the e function.Redirect Responses
To redirect the user to an entirely new location after the action is executed, you may use theActionResponse::redirect method:
ActionResponse::visit method:
ActionResponse::openInNewTab method:
Download Responses
To initiate a file download after the action is executed, you may use theActionResponse::download method. The download method accepts the desired name of the file as its first argument, and the URL of the file to be downloaded as its second argument:
Custom Modal Responses
In addition to the customization options provided before and during an action’s execution, Nova also supports the ability to present a custom modal response to the user. This allows you to provide additional context or follow-up actions to the user, customized to your use-case. For example, let’s imagine you have defined an action namedGenerateApiToken, which creates unique tokens for use with a REST API. Using a custom action response modal, you could show the user running the action a modal allowing them to copy the newly-generated API token to their clipboard.
Using the nova:asset Artisan command, you may generate a custom asset and register the custom modal with Nova’s Vue instance:
modal method within your action’s handle method, which will instruct Nova to show the modal after running the action, passing the Vue component’s name and any additional data you specify to the component. The data will be made available to the custom modal’s Vue component as props:
Queued Actions
Occasionally, you may have actions that take a while to finish running. For this reason, Nova makes it a cinch to queue your actions. To instruct Nova to queue an action instead of running it synchronously, mark the action with theShouldQueue interface:
--queued option when executing the nova:action Artisan command:
At this time, Nova does not support attaching
File fields to a queued action. If you need to attach a File field to an action, the action must be run synchronously.Customizing the Connection and Queue
You may customize the queue connection and queue name that the action is queued on by setting the$connection and $queue properties within the action’s constructor:
Job Batching
You may also instruct Nova to queue actions as a batch by marking the action with theLaravel\Nova\Contracts\BatchableAction interface. In addition, the action should use the Illuminate\Bus\Batchable trait.
When an action is batchable, you should define a withBatch method that will be responsible for configuring the action’s batch callbacks. This allows you to define code that should run after an entire batch of actions finishes executing against multiple selected resources. In fact, you can even access the model IDs for all of the resources that were selected when the batched action was executed:
Action Log
It is often useful to view a log of the actions that have been run against a particular resource. Additionally, when queueing actions, it’s often important to know when the queued actions have actually finished executing. Thankfully, Nova makes it a breeze to add an action log to a resource by attaching theLaravel\Nova\Actions\Actionable trait to the resource’s corresponding Eloquent model.
For example, we may attach the Laravel\Nova\Actions\Actionable trait to the User Eloquent model:

Disabling the Action Log
If you do not want to record an action in the action log, you may disable this behavior by adding awithoutActionEvents property on your action class:
withoutActionEvents method, you may disable the action log for an action when the action is attached to a resource. Disabling the action log is often particularly helpful when an action is often executed against thousands of resources at once, since it allows you to avoid thousands of slow, sequential action log database inserts:
Queued Action Statuses
While a queued action is running, you may update the action’s “status” for any of the models that were passed to the action via its model collection. For example, you may use the action’smarkAsFinished method to indicate that the action has completed processing a particular model:
markAsFailed method:
Action Modal Customization
By default, actions will ask the user for confirmation before running. You can customize the confirmation message, confirm button, and cancel button to give the user more context before running the action. This is done by calling theconfirmText, confirmButtonText, and cancelButtonText methods when defining the action: