Skip to content

petersowah/laravel-factory-dumps

Repository files navigation

Social Card of Laravel Activity Log

Easily export your Eloquent models to Excel and CSV formats.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package helps with exporting factory generated data and Eloquent collections to csv or xlsx formats.

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

Import the ExportableFactory trait in your model. Eg.

use PeterSowah\LaravelFactoryDumps\Traits\ExportableFactory;

Use the toExcel method to export the data to excel.

$user = User::factory(100)->create()->toExcel();

Use the toCsv method to export the data to csv.

$user = User::factory(100)->create()->toCsv();

You may also use the method toExcel and toCsv to export eloquent collections.

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

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

About

Export laravel factory collections to Excel or CSV dumps

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages