thiagovictorino/laravel-resource-exporter

A ServiceProvider that helps you to export a data resource from an api that returns a Laravel pagination payload

v0.0.6 2020-05-11 15:13 UTC

README

This package helps you to export a data resource from an api that returns a Laravel pagination payload (including bootstrap 3 payload).

Currently it is exporting for CSV, but any PR is welcome =)

Installation

Add package

composer require thiagovictorino/laravel-resource-exporter

Configuration

To create configuration file run:

php artisan vendor:publish --provider="Victorino\ResourceExporter\ResourceExporterServiceProvider"

Usage

/**
 * Getting the export builder 
 */

$exporter = \ResourceExporter::endpoint('http://yourl.com/resource?anyfilters');


/**
 * optional: Set the Bearer Token on request
 */
$exporter->withBearerToken('abcd123');

/**
 * optional: Set the payload as a Bootstrap 3 standard. You can set it automatically
 * on configurations
 */ 
$exporter->withBootstrapThree();

/**
 * optional: Add a delay between each requests
 */ 
$exporter->withDelay(5);

/**
 * Will save the file on disk that was set on configurations 
 */
$exporter->toCSV('my-file-name');

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email eu [at] thiagovictorino.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.