PHPackages                             cbytedigital/laravel-bi-data-export - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. cbytedigital/laravel-bi-data-export

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cbytedigital/laravel-bi-data-export
===================================

Laravel package for easily and periodically exporting data for BI purposes. Built in functionality for excluding or redacting columns and exporting to CSV on a Laravel filesystem disk.

v2.0.1(7mo ago)23.3k↓100%[1 issues](https://github.com/cbytedigital/laravel-bi-data-export/issues)MITPHPPHP ^8.2

Since Jun 12Pushed 7mo agoCompare

[ Source](https://github.com/cbytedigital/laravel-bi-data-export)[ Packagist](https://packagist.org/packages/cbytedigital/laravel-bi-data-export)[ RSS](/packages/cbytedigital-laravel-bi-data-export/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (7)Used By (0)

Laravel BI Data Export
======================

[](#laravel-bi-data-export)

[![PHP from Packagist](https://camo.githubusercontent.com/ad804021a288a06d7eae81d4b9f79bd97e4d80847a91aa67bc6362c5ea690332/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f63627974656469676974616c2f6c61726176656c2d62692d646174612d6578706f72742e737667)](https://packagist.org/packages/cbytedigital/laravel-bi-data-export)[![Latest Version on Packagist](https://camo.githubusercontent.com/d8f4f4ca1dcb86a714046ecd9f37654464e244f9bf8c2df8d63cdd44d107a50b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63627974656469676974616c2f6c61726176656c2d62692d646174612d6578706f72742e737667)](https://packagist.org/packages/cbytedigital/laravel-bi-data-export)[![Software License](https://camo.githubusercontent.com/439510bf3f53a97c6d83cac0f0ce3c23382ae6d0e005f36c084202ca07fa813f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f63627974656469676974616c2f6c61726176656c2d62692d646174612d6578706f72742e737667)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/cb241402aa540afa3c36fd709e107750d05d9aa1f5fc06d2733b7b51c7970503/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63627974656469676974616c2f6c61726176656c2d62692d646174612d6578706f72742e737667)](https://packagist.org/packages/cbytedigital/laravel-bi-data-export)

A [Laravel](https://laravel.com) package which can be used for easily and periodically exporting large datasets for BI purposes. Includes built in functionality for excluding or redacting columns and exporting to CSV on a Laravel filesystem disk.

The package uses database cursors and streaming to support working with large datasets and keep memory usage to a minimum for poor little webservers.

Installation
------------

[](#installation)

Use composer to install this package:

```
$ composer require cbytedigital/laravel-bi-data-export
```

Optional: The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:

```
'providers' => [
    // ...
    CbyteDigital\BiDataExport\BiDataExportServiceProvider::class,
];
```

You should publish the config with:

```
php artisan vendor:publish --provider="CbyteDigital\BiDataExport\BiDataExportServiceProvider"
```

Usage
-----

[](#usage)

Currently, only exporting to .CSV is supported. Which is the most usual method of exporting large datasets. Lucky, you can write your own implemention of a export job and reference the class in the config.

The export can be used directly in requests (sync), but it is recommended to use background workers and queueing.

To include your models for the export, configure your models to use the `BiExportable` trait.

```
class Client extends Model
{
    use BiExportable;
}
```

If desired define the selected and/or hidden fields in your model as follows (optional):

```
class Client extends Model
{
    use BiExportable;

    // Default behaviour
    public $biExportable = '*';

    // Or select specific columns
    public $biExportable = [
        'id',
        'username'
    ];

    // Values of hidden fields will be replaced
    public $biHidden = [
        'first_name',
        'last_name'
    ];

    // Define the placeholder value for hidden fields.
    // If not defined will resort to using the variable defined in the config.
    public $biHiddenText = 'REDACTED';
}
```

If you require to export for example a pivot table, which does usually not have a dedicated model, you can manually add the table and required columns/config for exporting to the configuration file.

There is also an option to add a custom log channel for all BI export logs. To use this, add a log channel name to your environment file.

Then, in your `logging.php` config file, add the channel to the `channels` array.

```
