Laravel Nova Excel 1.1 — Ready for launch

Patrick Brouwers
Spartner
Published in
2 min readOct 30, 2018

--

Two months ago we released a first version of Laravel Nova Excel that exports Nova resources to Excel. At Maatwebsite we still love Laravel Nova and couldn’t wait to extend our package even more!

Export what you see

Our main focus on this release was to try and get the data you see in the resource index screen to be exactly the same in the export. This meant we needed to redesign some of the internals that made the translation from Resources to our Laravel Excel library.

User resource index screen
Exported users

Exporting relations

In our opinion the most valuable addition is the possibility to export relation values. All BelongsTo relations added to the Resources fields will now be displayed in the same way as on the index screen.

BelongsTo::make('User'),

Alternatively you can also eager-load the relation and access its data.

public static $with = ['user'];public function fields(Request $request)
{
return [
Text::make('User Name', 'user.name'),
];
}

Computed fields

Another new addition is the possibility to export computed fields. They will be displayed just the same as in your index view.

Text::make('Random number', function () {
return str_random();
}),

Display callbacks

Laravel Nova Excel 1.1 now also calls display callbacks. All changes you have made to display the field in the index view will now also be respected when exporting.

Text::make('Name')
->displayUsing(function ($value) {
return strtoupper($value);
})

Improved lenses

We also took the time to improve the integration with lenses. Lenses will now also be exported with the same features as described above!

Improved heading row

When using ->withHeading() on the export action, it will now use the Field name instead of the attribute name. It’s still possible to override the heading row by passing the values in the ->withHeadings(['heading-1']) method.

(new DownloadExcel())->withHeadings(),

You can read more about Laravel Nova Excel in our dedicated documentation: https://laravel-excel.maatwebsite.nl/nova/1.1/getting-started/

Do you need help with integrating Laravel (Nova) Excel or do you need help building a Laravel application? At Maatwebsite, we are there to help you on a commercial basis. Contact us via info@maatwebsite.nl or via phone +31 (0)10 744 9312 to discuss the possibilities.

--

--

Patrick Brouwers
Spartner

Loves building awesome things in Laravel, VueJS and TailwindCss. Working @ Spartner. Maintainer of Laravel Excel.