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[2 PRs](https://github.com/petersowah/laravel-factory-dumps/pulls)MITPHPPHP ^8.3CI passing

Since Oct 28Pushed 1mo 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 1mo ago

READMEChangelog (4)Dependencies (16)Versions (9)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

36

—

LowBetter than 82% of packages

Maintenance71

Regular maintenance activity

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 51.7% of commits — single point of failure

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

418d 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] (9 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

9963.4M12](/packages/spatie-laravel-pdf)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[sunchayn/nimbus

A Laravel package providing an in-browser API client with automatic schema generation, live validation, and built-in authentication with a touch of Laravel-tailored magic for effortless API testing.

29428.0k](/packages/sunchayn-nimbus)[codebar-ag/laravel-flysystem-cloudinary

Cloudinary Flysystem v1 integration with Laravel

1224.9k2](/packages/codebar-ag-laravel-flysystem-cloudinary)[outerweb/image-library

Store and link files to your models

1113.0k2](/packages/outerweb-image-library)[tapp/filament-form-builder

User facing form builder using Filament components

131.2k1](/packages/tapp-filament-form-builder)

PHPackages © 2026

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