Excel Export for Laravel Nova

Excel Export for Laravel Nova

A common feature request from clients is the ability to export data to Excel, so they can create their own reports and a myriad of other things. Maatwebsite, the creators of Laravel Excel, recently launched a new Nova package named Laravel Nova Excel for just this purpose.

Integrating it with your Nova is really simple. First, require the package:

composer require maatwebsite/laravel-nova-excel

Next, go to a Nova resource. As an example app/Nova/User.php. Add Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel action to your actions() list.

<?php

namespace App\Nova;

use Illuminate\Http\Request;
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;

class User extends Resource
{
    /**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static $model = 'App\\User';

    // Other default resource methods

    /**
     * Get the actions available for the resource.
     *
     * @param  \Illuminate\Http\Request $request
     *
     * @return array
     */
    public function actions(Request $request)
    {
        return [
            new DownloadExcel(),
        ];
    }
}

After this, you’ll get the ability to export all the Users to an Excel file. Of course, this is just the minor highlights of the package and it can do many other things. Check out their getting started guide for full details on everything you might need.

Filed in: News / Excel / Nova
Laravel News Partners

Laravel Jobs

Senior Full-Stack Developer
Atlanta, GA - (remote) USA ONLY
Curricula
PHP Laravel Developer
London
Investoo
Senior Backend Developer
Australia
Tixel
CTO
Copenhagen
Tjommi
Looking for Senior Full-stack Laravel/React.js Javascript API Developer - Immediate (Full-time)
Remote
ApproveMe // Document Signing

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.