承接 naimsolong/laravel-data-extractor 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

naimsolong/laravel-data-extractor

最新稳定版本:1.0.1

Composer 安装命令:

composer require naimsolong/laravel-data-extractor

包简介

A data extractor based on models and it's relationship

README 文档

README

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

A Laravel package for extracting data from Eloquent models and their relationships with flexible configuration options. This package provides a simple and intuitive way to extract structured data from your models, making it perfect for API responses, data exports, or any scenario where you need to transform model data into a specific format.

What It Does

The extractor leverages Laravel's relationship system to automatically include related data based on your configuration, while providing fine-grained control over which fields are included or excluded from the extraction process.

You can use the available options inside config file:

use NaimSolong\DataExtractor\Extract;

// Option
(new Extract)
  ->option('User')
  ->queryId(4)
  ->toSql();

// Source
(new Extract)
  ->source('session')
  ->queryId(3)
  ->toSql();

Or you can use model that you have queried:

use NaimSolong\DataExtractor\Extract;
use App\Models\User;

// Extract directly
(new Extract)
  ->toSql(
    User::get()
  );

Installation

You can install the package via composer:

composer require naimsolong/laravel-data-extractor

You can publish the config file with:

php artisan vendor:publish --tag="data-extractor-config"

This is the contents of the published config file:

return [
    'is_enabled' => env('DATA_EXTRACTOR_ENABLED', false),

    'options' => [
        [
            'name' => 'Default',
            'description' => 'Extra all user data',
            'format' => 'sql',
            'source' => 'default',
        ],
    ],

    'source' => [
        'default' => [
            'connection' => 'mysql',
            'model' => User::class,
            'relationships' => [
                'mainProfile',
            ],
        ],
    ],
];

Testing

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-14