Registering actions in Nova.
actions
method. To attach an action to a resource, you should simply add it to the array of actions returned by this method:
make
method to instantiate your action. Any arguments passed to the make
method will be passed to the constructor of your action:
canSee
method when registering your action. The canSee
method accepts a closure which should return true
or false
. The closure will receive the incoming HTTP request:
Method | Return Type | Description |
---|---|---|
allResourcesSelected | bool | Returns true if “Select all” selected. |
selectedResourceIds | \Illuminate\Support\Collection|null | Returns null if “Select all” selected or returns a collection of selected resource IDs. |
selectedResources | \Illuminate\Support\Collection|null | Returns null if “Select all” selected or returns a collection of resource models. |
canRun
method in conjunction with the canSee
method to have full control over authorization in this scenario. The callback passed to the canRun
method receives the incoming HTTP request as well as the model the user would like to run the action against:
canSee
and canRun
authorization methods, Nova will also determine if the resource’s corresponding model policy has runAction
and runDestructiveAction
methods. Finally, Nova will determine if the user is authorized to update
the model or, in the case of destructive actions, delete
the model based on the model’s policy methods.
The priority for authorizing the execution of a Nova action is best explained by the following list of steps:
canRun
method if the method is defined.runAction
or runDestructiveAction
methods if those methods have been defined.update
or delete
methods if those methods have been defined.false
.onlyOnIndex
exceptOnIndex
showOnIndex
onlyOnDetail
exceptOnDetail
showOnDetail
onlyInline
exceptInline
showInline
showInline
method when attaching the action to the resource:
standalone
method when registering the action. These actions always receives an empty collection of models in their handle
method:
sole
action, Nova will only display the action when a single resource is selected. Sole actions still receive a collection in their handle
method, but the collection will only contain a single model:
belongsToMany
fields so that they can operate on pivot / intermediate table records. To accomplish this, you may chain the actions
method onto your field’s definition:
referToPivotAs
method:
using
factory method on the Action
class, passing the action’s name and a closure. The closure given to the using
method receives the same parameters as a dedicated action’s handle
method:
ShouldQueue
trait provided by Laravel.redirect
action will redirect the user to an external URL. To create a redirect
action, pass the action name and the URL you would like to redirect the user to:
visit
action will push the user to an internal page inside Nova. To create a visit
action, pass the action’s name and the path you want them to visit:
danger
action displays an error toast notification to the user. For instance, your Nova application may have an action that was previously available but is no longer available, and to avoid confusion you may wish to notify the user of its removal. To accomplish this, pass the action name and the message to display to the user:
modal
action allows you to display a custom modal to the user. To create a modal
action, pass the action name, your custom Vue component, and any additional data that should be made available to the component:
openInNewTab
action opens a URL in a new browser tab. To create an openInNewTab
action, pass the action name and the URL that should be opened in the new browser tab:
downloadUrl
action downloads the file at the given URL. To create a downloadUrl
action, pass the action name and the URL of the file to be downloaded:
fullscreen
method when registering your action with a given resource:
size
method:
withoutConfirmation
method when registering your action with a given resource: