PHP code example of naimsolong / laravel-data-extractor

1. Go to this page and download the library: Download naimsolong/laravel-data-extractor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

naimsolong / laravel-data-extractor example snippets


use NaimSolong\DataExtractor\Extract;

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

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

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

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

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

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

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

    'export' => [
        'default' => [
            'file_name' => 'data-extractor',
            'file_path' => 'data-extractor',
            'disk' => 'local',
        ],
    ],
];