Learn how to define, register, and customize Nova resources.
app/Nova
directory of your application. You may generate a new resource using the nova:resource
Artisan command:
model
property. This property tells Nova which Eloquent model the resource corresponds to:
ID
field definition. Don’t worry, we’ll add more fields to our resource soon.
app/Nova
directory will automatically be registered with Nova. You are not required to manually register them.app/Providers/NovaServiceProvider.php
file. This file contains various configuration and bootstrapping code related to your Nova installation.
As mentioned above, you are not required to manually register your resources; however, if you choose to do so, you may do so by overriding the resources
method of your NovaServiceProvider
.
There are two approaches to manually registering resources. You may use the resourcesIn
method to instruct Nova to register all Nova resources within a given directory. Alternatively, you may use the resources
method to manually register individual resources:
Dashboard
displayInNavigation
property of your resource class:
menu
method on your resource class:
group
property of your resource class:
$tableStyle
property or the static tableStyle
method on your resource class:
Tight Table Style
$showColumnBorders
property or the static showColumnBorders
method on your resource class:
true
will instruct Nova to display the table with borders on every table item:
Table Column Borders
clickAction
property on the resource’s class:
select
option will select the resource row’s checkbox. The ignore
option instructs Nova to ignore click events altogether.
with
property of your resource. This property instructs Nova to always eager load the listed relationships when retrieving the resource.
For example, if you access a Post
resource’s user
relationship within the Post
resource’s subtitle
method, you should add the user
relationship to the Post
resource’s with
property:
Resource Replication
replicate
method on the resource class:
Markdown
and Trix
fields that use the withFiles
method may not be replicated.fromResourceId
value on the replication request. Typically, this value would be accessed from an event listener or observer that is listening for the model’s creating
event:
save
, delete
, forceDelete
, restore
Eloquent methods you are familiar with. Therefore, it is easy to listen for model events triggered by Nova and react to them. The easiest approach is to simply attach a Laravel model observer to a model:
make
method provided by the Laravel\Nova\Observable
class. Typically, this should be done within your application’s NovaServiceProvider
:
Observer
itself using Nova’s whenServing
method:
afterCreate
afterUpdate
afterDelete
afterForceDelete
afterRestore
409 Conflict
HTTP status code and display an error message to prevent unintentional model changes. This may occur if another user updates the model after you have opened the “Edit” page on the resource. This feature is also known as the Nova “Traffic Cop”.
trafficCop
property to false
on a given resource class:
trafficCop
method on the resource if you have more intense customization needs in order to determine if this feature should be enabled:
polling
property of your Resource class:
pollingInterval
property on your resource class with the number of seconds Nova should wait before fetching new resource records:
showPollingToggle
property on your resource class to true
:
Resource Polling
visit
method. Because of this, redirection is limited to paths within Laravel Nova. You may invoke the URL::remote
method to redirect to an external URL:
redirectAfterCreate
method:
redirectAfterUpdate
method:
redirectAfterDelete
method:
Simple Pagination
Load-more Pagination
Links Pagination
load-more
or links
styles by changing the value of the pagination
configuration option within your application’s config/nova.php
configuration file:
perPageOptions
property:
perPageOptions
method on your application’s base Resource
class, which is created when you install Nova:
perPageOptions
on your Resource
will cause Nova to fetch the number of resources equal to the first value in the perPageOptions
array.$perPageViaRelationship
property, you may also customize the number of resources displayed when a particular resource is displayed on another resource’s detail view as a relationship:
Laravel\Nova\Actions\ExportAsCsv
action to your Nova resource:
nameable
method when registering the action:
withFormat
method when registering the action:
debounce
property on the resource class:
C
key on a resource index to navigate to the “Create Resource” page. On the resource detail page, the E
key may be used to navigate to the “Update Resource” page.