hexagonlabsllc/laravel-exports

Comprehensive export feature that utilizes Laravel's model backbone to create customizable exports.

Maintainers

Package info

github.com/HexagonLabsLLC/laravel-exports

pkg:composer/hexagonlabsllc/laravel-exports

Statistics

Installs: 45

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0-rc.3 2025-12-14 13:59 UTC

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:

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:

License

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