Dependency Upgrades
Nova’s upstream dependencies have been upgraded. You will find a complete list of our dependency upgrades below:Server
- PHP 7.3+
- Laravel Framework 8.0+
- Updated
doctrine/dbalfrom^2.9to^2.13.3|^3.1.2|^4.0 - Updated
laravel/uifrom^2.0|^3.0to^3.3|^4.0 - Updated
symfony/*from^5.0to^5.4|^6.0|^7.0 - Removed
cakephp/chronosandmoontoast/mathdependencies
Client
- Updated supported Laravel Mix version from
v1tov6 - Removed
flatpickrandmoment.js
Updating Composer Dependencies
You should update yourlaravel/nova dependency to ^4.0 in your application’s composer.json file:
Updating Configuration, Assets, and Translations
Next, you should update your application’s Nova configuration, assets, and translation files. To get started, you may run the following commands to update your assets and translations. You may wish to store a copy of your current translation file before running this command so you can easily port any custom translations back into the new file after running these commands. In addition, we will generate a “Main” dashboard for your Nova installation:middleware and api_middleware configuration options within your application’s nova configuration file appear as follows:
config/nova.php
nova configuration file contains a storage_disk configuration option:
config/nova.php
Registering a Nova License Key and Production URL
Nova requires a license key a production URL to be used in production environments. Nova will check your license key and the current host against the values from the license details found in your Nova account. You can learn more in the installation docs.Updating Third-Party Nova Packages
If your application relies on Nova tools or packages developed by third-parties, it is possible that these packages are not yet compatible with Nova 4.0 and will require an update from their maintainers.High Impact Changes
Nova Request
Nova 4 updates a variety of methods to accept aLaravel\Nova\Http\Requests\NovaRequest instance instead of an Illuminate\Http\Request instance. An overview of the methods that have been updated is provided below so you may update your method signatures accordingly.
Resources
Thefields, fieldsForIndex, fieldsForDetail, fieldsForCreate, fieldsForUpdate, cards, filters, lenses, and actions methods:
Lenses
Thefields, filters, and actions methods:
Actions
Thefields method:
Filters
Theapply and options methods:
Main Dashboard Class
In previous releases of Nova, the “Main” dashboard cards were defined via thecards method of your application’s NovaServiceProvider. However, in Nova 4, a dedicated Main dashboard class must be created via the following command:
cards method from your NovaServiceProvider to the cards method of your new App\Nova\Dashboards\Main class and register the Main dashboard within the dashboards method of your NovaServiceProvider:
Dashboard Methods
In Nova 4, thelabel and uriKey methods defined on dashboard classes are no longer static. You should update your methods accordingly:
Client-Side Timezone Detection
Nova 4 removes the ability to rely on the client machine’s timezone in order to display timezone related information. Instead, Nova 4 utilizes the application’s “server side” timezone as defined by the timezone option in your application’sapp configuration file.
Please refer to our documentation regarding timezone customization for more information.
Date / DateTime Fields & HTML5
Nova 4 utilizes native <input type="date" /> and <input type="datetime-local" /> elements to render the Date and DateTime fields. Therefore, the following methods have been removed from Nova 4:
firstDayOfWeek()format()pickerFormat()pickerDisplayFormat()incrementPickerHourBy()incrementPickerMinuteBy()
Algolia Place Field
Unfortunately, Algolia is retiring their “Places” API on May 31, 2022; therefore, thePlace field has been deprecated and we encourage you to migrate to Text fields for street addresses and cities.
Medium Impact Changes
Updating Custom Tool, Cards, Fields, Filters
To ease upgrading custom packages to Nova 4, please review and copy the following files from Laravel Nova’ssrc/Console/tool-stubs directory to your own custom package:
nova.mix.jspackage.jsonwebpack.mix.js:::
Vue 3
This change primarily affects the installation of custom tools that utilize Vue routing. Nova 4 has been updated to use Vue 3, in order to upgrade all custom cards, custom fields, custom filters, resource tools, and tools to support Vue 3, please make the following changes to your application’swebpack.mix.js:
Replacing Vue Router With Inertia.js
This change primarily affects the installation of custom tools that utilize Vue routing. Nova 4 has replaced Vue router with Inertia.js. Therefore, custom tools should migrate from registering Vue routes to registering Inertia.js page components and backend routes. For example, given the following Nova 3 Vue router registration:Removal of laravel-nova NPM Dependency
This change primarily affects the installation of custom tools that utilize Vue routing.
To ease upgrading custom packages to support Nova 4, please review and copy the following files from Laravel Nova’s
src/Console/stubs especially the following files:nova.mix.jspackages.jsonwebpack.mix.js
laravel-nova NPM package. In 4.0, this is no longer the case as each mixin has been integrated into Nova itself. To upgrade any custom packages you’ve created, you must update your webpack.mix.js file to define an alias to vendor/laravel/nova/resources/js/mixins/packages.js:
Typically, custom Nova tools, resource tools, cards, and other custom packages that are being developed within a nova-components directory of a Laravel application can reference Nova’s own packages.js file by defining a laravel-nova alias that points to the file within the Nova installation that is located within your root application’s vendor directory. This alias is typically defined within the custom package’s nova.mix.js file:
nova-components directory should declare laravel/nova as a “dev” Composer dependency, and then define a laravel-nova Mix alias that points to the packages.js file within your custom package’s vendor directory:
laravel-nova mixins you are required to prepare laravel/nova’s node_modules by running the following command:
Event Cancellation on Save
Nova 3 ignores event cancellation when creating or updating a resource. For example, the following code will still persist theUser resource to the database, even though the event listener returns false:
Laravel\Nova\Exceptions\ResourceSaveCancelledException exception in Nova 4.
Field::default Method Only Applies to Create, Attach, & Action Requests
Nova 4 will no longer resolve default values for “index” and “detail” requests. If you need to define a model’s default attribute values, please utilize Eloquent’s $attributes property:
Relationship Name Conventions
Given the following field definition, Nova 3 will assume the relationship method is namedpurchased_books; however, Nova 4 will correctly assume the relationship method is named purchasedBooks.
Action::actionClass Method Removed
Nova 4 no longer allows adding custom CSS styles to an action confirmation modal’s buttons via the action’s actionClass method.
Low Impact Changes
Eloquent User Provider Required
Nova 4 requires the authentication user provider to beeloquent in order to resolve information regarding the currently authenticated user.
In your application’s default config/auth.php configuration file, the Eloquent user provider is specified and it is instructed to use the App\Models\User model when retrieving users. You may change these values within your configuration file based on the needs of your application.
Reduce Encoded Filter String Length
Nova 4 introduces a shorter key-value map in filter string URLs which reduces the overall length of the URL. This change doesn’t affect bookmarked URLs; however, third party package tool developers who interact deeply with Vuex may wish to ensure their packages still work after this change.Action::showOnTableRow Method
The Action::showOnTableRow method has been deprecated. Instead, we suggest updating your code to use the showInline method:
Authorization Precedence
Nova 4 introduce the following tweaks to authorization order / precedence:- Authorizing if a user can
viewa resource no longer depends on theviewAnypermission. - Actions can be executed regardless of
viewandviewAnypermissions. - Destructive actions will now authorize via their own
canRunmethod before falling back to the model’s policy.
Update Published Stubs
Due to various changes in Nova 4.0, you should re-publish the Nova “stubs” if you have previously published them. You can accomplish this by executing thenova:stubs Artisan command with the --force option: