PHPackages                             petersowah/laravel-factory-dumps - 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. petersowah/laravel-factory-dumps

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

petersowah/laravel-factory-dumps
================================

Export Laravel factory data to CSV or Excel files

0.0.4(1y ago)25[1 PRs](https://github.com/petersowah/laravel-factory-dumps/pulls)MITPHPPHP ^8.3CI passing

Since Oct 28Pushed 1w ago1 watchersCompare

[ Source](https://github.com/petersowah/laravel-factory-dumps)[ Packagist](https://packagist.org/packages/petersowah/laravel-factory-dumps)[ Docs](https://github.com/petersowah/laravel-factory-dumps)[ GitHub Sponsors](https://github.com/petersowah)[ RSS](/packages/petersowah-laravel-factory-dumps/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (16)Versions (11)Used By (0)

[![Social Card of Laravel Activity Log](/art/social-card.svg)](/art/social-card.svg)

Easily export your Eloquent models to Excel and CSV formats.
============================================================

[](#easily-export-your-eloquent-models-to-excel-and-csv-formats)

[![Latest Version on Packagist](https://camo.githubusercontent.com/117ea7d0b574533aa0fad5b5bf554f432d599739209d7f8ea4eb33630fad44d6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7065746572736f7761682f6c61726176656c2d666163746f72792d64756d70732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/petersowah/laravel-factory-dumps)[![GitHub Tests Action Status](https://camo.githubusercontent.com/5c2d4cc37fdbf7e4409b1eb2155ddfcab262963cf750ecfe320f0b2d86d39bca/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7065746572736f7761682f6c61726176656c2d666163746f72792d64756d70732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/petersowah/laravel-factory-dumps/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/2ef7284f66171d7f6b4241af252203a28fde423d72ba973288581d9fcac6c3a0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7065746572736f7761682f6c61726176656c2d666163746f72792d64756d70732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/petersowah/laravel-factory-dumps/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/c2a46cda7b480ea7c9dd21b8403bce4a99f68bfc0273e2a6afa9f2f6aeafd2a9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7065746572736f7761682f6c61726176656c2d666163746f72792d64756d70732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/petersowah/laravel-factory-dumps)

This package helps with exporting factory generated data and Eloquent collections to CSV or Excel formats. It provides a simple and intuitive way to export your data with support for custom column selection and renaming.

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

[](#installation)

You can install the package via composer:

```
composer require petersowah/laravel-factory-dumps
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-factory-dumps-config"
```

This is the contents of the published config file:

```
return [
    'path' => env('FACTORY_DUMPS_PATH', __DIR__.'/../workbench/database/dumps'),
];
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

1. Import the `ExportableFactory` trait in your model:

```
use PeterSowah\LaravelFactoryDumps\Traits\ExportableFactory;

class User extends Model
{
    use ExportableFactory;
    // ...
}
```

2. Export factory-generated data:

```
// Export to Excel
$users = User::factory(100)->create()->toExcel();

// Export to CSV
$users = User::factory(100)->create()->toCsv();
```

3. Export Eloquent collections:

```
$users = User::whereNotNull('email_verified_at')->get();
$users->toExcel();
$users->toCsv();
```

### Advanced Usage

[](#advanced-usage)

#### Custom Filenames

[](#custom-filenames)

You can specify custom filenames for your exports:

```
$users = User::factory(100)->create();
$users->toExcel('custom_users.xlsx');
$users->toCsv('custom_users.csv');
```

#### Column Selection and Renaming

[](#column-selection-and-renaming)

The package provides a powerful `pluck` method that allows you to select and rename columns:

```
$users = User::factory(100)->create();

// Select a single column
$users->pluck('name')->toExcel();

// Select multiple columns
$users->pluck(['name', 'email'])->toExcel();

// Select and rename columns
$users->pluck([
    'name' => 'Full Name',
    'email' => 'Email Address',
    'created_at' => 'Registration Date'
])->toExcel();
```

You can also use Laravel's `select` method to specify which columns to export:

```
// Select specific columns and export to CSV
$users = User::factory(5)->create()
    ->select(['full_name', 'email'])
    ->toCsv('users-name-email.csv');

// Select specific columns and export to Excel
$users = User::factory(5)->create()
    ->select(['full_name', 'email'])
    ->toExcel('users-name-email.xlsx');
```

#### Custom Column Selection for Excel

[](#custom-column-selection-for-excel)

You can specify which columns to export to Excel:

```
$users = User::factory(100)->create();
$users->toExcel(null, ['name', 'email', 'created_at']);
```

### File Locations

[](#file-locations)

- CSV files are stored in `database/dumps/csv/`
- Excel files are stored in `storage/app/dumps/excel/` (or `workbench/database/dumps/excel/` during testing)

The default filename is based on the model's table name (e.g., `users.xlsx` or `users.csv`). For non-model data, it defaults to `export.xlsx` or `export.csv`.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [petersowah](https://github.com/petersowah)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance73

Regular maintenance activity

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Total

4

Last Release

471d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/33dae31a3741ab0144f7e5a537334beea594b6b1989e26124446b47b6d43397a?d=identicon)[petersowah](/maintainers/petersowah)

---

Top Contributors

[![petersowah](https://avatars.githubusercontent.com/u/6297425?v=4)](https://github.com/petersowah "petersowah (15 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

csvexcelfactorylaravellaravelpetersowahlaravel-factory-dumps

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/petersowah-laravel-factory-dumps/health.svg)

```
[![Health](https://phpackages.com/badges/petersowah-laravel-factory-dumps/health.svg)](https://phpackages.com/packages/petersowah-laravel-factory-dumps)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M307](/packages/laravel-horizon)[statamic/cms

The Statamic CMS Core Package

4.8k3.6M993](/packages/statamic-cms)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[elegantly/laravel-invoices

Store invoices safely in your Laravel application

23546.8k2](/packages/elegantly-laravel-invoices)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
