Learn how to register metrics in Nova.
cards
method. To attach a metric to a resource, you should simply add it to the array of metrics / cards returned by this method:
onlyOnDetail
method when registering your metric:
calculate
method may access the resourceId
property on the incoming $request
:
Help
card. To add a metric to your dashboard, add the metric to the array of cards returned by the cards
method of your Dashboard class:
canSee
method when registering your metric. The canSee
method accepts a closure which should return true
or false
. The closure will receive the incoming HTTP request:
Authorizable
trait’s can
method on our User
model to determine if the authorized user is authorized for the viewUsersPerDay
action. However, since proxying to authorization policy methods is a common use-case for canSee
, you may use the canSeeWhen
method to achieve the same behavior. The canSeeWhen
method has the same method signature as the Illuminate\Foundation\Auth\Access\Authorizable
trait’s can
method:
defaultRange
method of the metric to accomplish this:
width
method when registering the metric:
full
, the height of the card will become dynamic. You may explicitly define this behaviour by calling the fixedHeight
or dynamicHeight
methods:
help
method while registering your metric. The help
method receives the help text as its only argument:
help
method:
Event | Behaviour |
---|---|
Resource Deleted | Automatic Update |
Resource Restored | Automatic Update |
Action Executed | Only update if the metric’s refreshWhenActionsRun method is invoked during registration |
Filter Change | Only update if the metric’s refreshWhenFiltersChange method is invoked during registration |
refreshWhenActionsRun
method when registering your metric:
refreshWhenFiltersChange
method is invoked when the metric is registered: