PHPackages                             rikless/xporter - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. rikless/xporter

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

rikless/xporter
===============

CSV wrapper to export eloquent query result

2.0.2(4y ago)105.2k1[1 PRs](https://github.com/Francois-Francois/xporter/pulls)MITPHPCI passing

Since Mar 15Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Francois-Francois/xporter)[ Packagist](https://packagist.org/packages/rikless/xporter)[ RSS](/packages/rikless-xporter/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (16)Used By (0)

Laravel CSV Xporter
-------------------

[](#laravel-csv-xporter)

Xporter is a CSV wrapper allowing you to export Eloquent query results from your laravel application, using league/csv package. With help of Laravels Xporter class creates exportable schema that can be easy modified and reused.

Documentation
-------------

[](#documentation)

### Installation

[](#installation)

Run:

```
composer require rikless/xporter:1.*
```

### Example usage

[](#example-usage)

Create a simple class where you'll have all your export parameter anywhere in your application. `App\Exports` may be a good place to start. You'll need to extend the `Rikless\Xporter\Exportable` class.

Now complete `convert()`, `query()` methods and `xportable`, `rootModel` properties.

You have to use the `convert()` methods to transform your data, and add data from relationship.

In your query method, you just need to instantiate your model and add your query. It can be anything from a `Request` object in your controller. Be aware to not use the `get()` or `all()` method in you query, because the package will chunk results. This mean that it needs an `Illuminate\Database\Eloquent\Builder` object.

```
