Skip to content

eithed/export-to-csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

ExportToCsv Action for Laravel Nova

Exports given view (be it Laravel Lens or Resource) to a CSV file

Installation

composer require eithed/export-to-csv

Usage

Within your view, per Nova documentation use the action:

public function actions(Request $request)
{
    return [
        new Eithed\ExportToCsv($this),
    ];
}

By default CSVs are saved within public/exports folder.

Customization

If a custom job needs to be run after export has finished you'll need to extend this class as such:

namespace App\Nova\Actions;

use App\Jobs\NotifyUserOfCompletedExport;

class ExportToCsv extends \Eithed\ExportToCsv\ExportToCsv
{
    protected function onFinish()
    {
        dispatch(new NotifyUserOfCompletedExport($this->user, $this->path));
    }
}

Unfortunately because Action itself is serialized this is the only sensible way that came to my mind to customize actions onFinish.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages