hexagonlabsllc / laravel-exports
Comprehensive export feature that utilizes Laravel's model backbone to create customizable exports.
v1.0.0-rc.3
2025-12-14 13:59 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^11.0||^12.0
- illuminate/support: ^12.12
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1
- orchestra/testbench: ^9.0.0||^10.0.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
This package is auto-updated.
Last update: 2026-03-24 21:33:45 UTC
README
A powerful, database-driven export system for Laravel applications that provides dynamic, configurable exports without writing code.
Features
- Database-Driven Configuration - Define exports through database records, not code
- Dynamic Model Discovery - Auto-import Eloquent models and their relationships
- Advanced Filtering - Static filters, request-based filters, and collection filters
- Nested Relationship Support - Export deeply nested data using dot notation
- Pivot Table Data - Access BelongsToMany pivot attributes via
.pivot.notation - Transformation Functions - 22 built-in functions for formatting dates, strings, numbers
- Aggregations - Sum, count, average, min, max, first, last on collections
- Large Dataset Support - Chunking, streaming, and background job processing
- Multiple Formats - CSV and JSON out of the box, extensible for more
Documentation
Full documentation is available in the docs directory:
- Getting Started - Installation and setup
- Configuration - All configuration options
- Guides - In-depth guides for each feature
- Examples - Practical examples from basic to advanced
- API Reference - Complete class and method documentation
- Troubleshooting - Common issues and solutions
Quick Start
Installation
composer require hexagonlabsllc/laravel-exports
Setup
# Publish configuration and migrations php artisan vendor:publish --provider="HexagonLabsLLC\LaravelExports\LaravelExportsServiceProvider" # Run migrations php artisan migrate # Import your models with relationships php artisan export:import-models --deep # Seed transformation functions php artisan export:seed-functions
Basic Usage
use HexagonLabsLLC\LaravelExports\Models\{ExportModel, ExportLayout, ExportColumn}; use HexagonLabsLLC\LaravelExports\Services\DynamicExportService; // 1. Create an export layout $userModel = ExportModel::where('title', 'User')->first(); $layout = ExportLayout::create([ 'export_model_id' => $userModel->id, 'title' => 'User Export', ]); // 2. Define columns ExportColumn::create([ 'export_layout_id' => $layout->id, 'title' => 'Name', 'value_path' => 'name', 'position' => 1, ]); ExportColumn::create([ 'export_layout_id' => $layout->id, 'title' => 'Email', 'value_path' => 'email', 'position' => 2, ]); // 3. Export data $service = new DynamicExportService(); return $service->downloadAs($layout, 'csv', 'users.csv');
Related Data
Export data from relationships using dot notation:
ExportColumn::create([ 'export_layout_id' => $layout->id, 'title' => 'Department', 'value_path' => 'department.name', 'position' => 3, ]);
Request-Based Filtering
Add dynamic filters controlled by request parameters:
ExportFilter::create([ 'export_layout_id' => $layout->id, 'export_model_relation_id' => $statusRelation->id, 'operator' => '=', 'is_request' => true, ]); // In your controller $service->downloadAs($layout, 'csv', 'users.csv', [ 'status' => 'active', ]);
Large Datasets
For large exports, use streaming or background jobs:
// Streaming return $service->streamAs($layout, 'csv', 'large.csv', [], [], 1000); // Background job $exportId = $service->queueExport($layout, 'csv'); $status = ProcessExportJob::getStatus($exportId);
Requirements
- PHP 8.2+
- Laravel 12.0+
- Database with UUID support
Learn More
See the full documentation for:
- Nested Relationships - Deep data traversal
- Pivot Tables - BelongsToMany pivot data
- Transformation Functions - All 22 functions
- Aggregations - Collection aggregation
- Large Datasets - Performance optimization
- Background Jobs - Queue processing
License
The MIT License (MIT). Please see License File for more information.