Introduction
Laravel Nova is a beautiful administration dashboard for Laravel applications. Of course, the primary feature of Nova is the ability to administer your underlying database records using Eloquent. Nova accomplishes this by allowing you to define a Nova “resource” that corresponds to each Eloquent model in your application.Defining Resources
By default, Nova resources are stored in theapp/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:
app/Nova/Post.php
ID
field definition. Don’t worry, we’ll add more fields to our resource soon.
Nova contains a few reserved words which may not be used for resource names:
- Card
- Dashboard
- Field
- Impersonate
- Metric
- Resource
- Search
- Script
- Style
- Tool
Registering Resources
By default, all resources within the
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:
app/Providers/NovaServiceProvider.php

Dashboard
displayInNavigation
property of your resource class:
app/Nova/Post.php
Customizing Resource Menus
You can customize the resource’s menu by defining amenu
method on your resource class:
app/Nova/Post.php
Grouping Resources
If you would like to separate resources into different sidebar groups, you may override thegroup
property of your resource class:
app/Nova/Post.php
Resource Table Style Customization
Nova supports a few visual customization options for your resources.Table Styles
Sometimes it’s convenient to show more data on your resource index tables. To accomplish this, you can use the “tight” table style option designed to increase the visual density of your table rows. To accomplish this, override the static$tableStyle
property or the static tableStyle
method on your resource class:
app/Nova/Post.php

Tight Table Style
Column Borders
You can instruct Nova to display column borders by overriding the static$showColumnBorders
property or the static showColumnBorders
method on your resource class:
app/Nova/Post.php
true
will instruct Nova to display the table with borders on every table item:

Table Column Borders
Resource Table Click Action
By default, when clicking on a resource table row, Nova will navigate to the detail view for the resource. However, you may want Nova to navigate to the edit form instead. You can customize this behavior by changing theclickAction
property or the static clickAction
method on your resource class:
select
option will select the resource row’s checkbox. The ignore
option instructs Nova to ignore click events altogether.
Eager Loading
If you routinely need to access a resource’s relationships within your fields, resource title, or resource subtitle, it may be a good idea to add the relationship to thewith
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:
app/Nova/Post.php
Resource Default Attribute Values
By default, Laravel Nova will utilize the default attribute values defined by Eloquent over any default values set on each Field during resource creation. If you need to override the default values within a resource, you can do so by overriding the resource’sdefaultAttributes
method:
Resource Replication
Sometimes, you may want to create a new resource while using all of the data from an existing resource as a starting point. Nova’s resource replication feature does just that. After clicking the replicate button, you’ll be whisked away to a resource creation form with all of the replicated resource’s data hydrated into the form and ready for tweaking:
Resource Replication
replicate
method on the resource class:
app/Nova/Post.php
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:
app/Observers/PostObserver.php
Resource Events
All Nova operations use the typicalsave
, 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:
app/Providers/AppServiceProvider.php
make
method provided by the Laravel\Nova\Observable
class. Typically, this should be done within your application’s NovaServiceProvider
:
app/Providers/AppServiceProvider.php
Observer
itself using Nova’s whenServing
method:
app/Observers/UserObserver.php
Resource Hooks
Nova also allows you to define the following static methods on a resource to serve as hooks that are only invoked when the corresponding resource action is executed from within Laravel Nova:afterCreate
afterUpdate
afterDelete
afterForceDelete
afterRestore
app/Nova/User.php
Preventing Conflicts
If a model has been updated since it was last retrieved by Nova, Nova will automatically respond with a409 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”.
Disabling Traffic Cop
If you are not concerned with preventing conflicts, you can disable the Traffic Cop feature by setting thetrafficCop
property or trafficCop
method return to false
on a given resource class:
If you are experiencing issues with traffic cop you should ensure that your system time is correctly synchronized using NTP.
Resource Polling
Nova can automatically fetch the latest records for a resource at a specified interval. To enable polling, override thepolling
property of your Resource class:
app/Nova/User.php
pollingInterval
property on your resource class with the number of seconds Nova should wait before fetching new resource records:
app/Nova/User.php
Toggling Resource Polling
By default, when resource polling is enabled, there is no way to disable it once the page loads. You can instruct Nova to display a start / stop toggle button for resource polling by setting theshowPollingToggle
property on your resource class to true
:
app/Nova/User.php

Resource Polling
Redirection
Nova allows you to easily customize where a user is redirected after performing resource actions such as creating or updating a resource: Behind the scenes, Nova’s redirect features use Inertia.js’svisit
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:
After Creating Redirection
You may customize where a user is redirected after creating a resource using by overriding your resource’sredirectAfterCreate
method:
app/Nova/User.php
After Updating Redirection
You may customize where a user is redirected after updating a resource using by overriding your resource’sredirectAfterUpdate
method:
app/Nova/User.php
After Deletion Redirection
You may customize where a user is redirected after deleting a resource using by overriding your resource’sredirectAfterDelete
method:
app/Nova/User.php
Pagination
Nova has the ability to show pagination links for your Resource listings. You can choose between three different styles: “simple”, “load-more”, and “links”, depending on your application’s needs:
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:
config/nova.php
Customizing Pagination
If you would like to customize the selectable maximum result amounts shown on each resource’s “per page” filter menu, you can do so by customizing the resource’sperPageOptions
property or perPageOptions
method:
Changing the value of
perPageOptions
on your Resource
will cause Nova to fetch the number of resources equal to the first value in the perPageOptions
array.$perPageViaRelationshipOptions
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:
CSV Export
Occasionally you may need to export a group of resource records as a CSV file so that you can interact with the data in a spreadsheet application or import the data into another system. Thankfully, Nova includes built-in support for exporting resource data. To get started, add theLaravel\Nova\Actions\ExportAsCsv
action to your Nova resource:
app/Nova/User.php
nameable
method when registering the action:
app/Nova/User.php
withFormat
method when registering the action:
app/Nova/User.php
Resource Index Search Debounce
You may wish to customize the search debounce timing of an individual resource’s index listing. For example, the queries executed to retrieve some resources may take longer than others. You can customize an individual resource’s search debounce by setting thedebounce
property on the resource class:
app/Nova/User.php
Keyboard Shortcuts
You may press theC
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.