PHP code example of edujugon / tablediff

1. Go to this page and download the library: Download edujugon/tablediff 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/ */

    

edujugon / tablediff example snippets


$diff = new \Edujugon\TableDiff\TableDiff();

$diff->tables('base_table', 'merge_table');

$diff->pivots('base_table_pivot', 'merge_table_pivot');

$diff->pivot('pivot_name');

$report = $diff->run()->withReport();

$report = $diff->tables('base_table','merge_table')
            ->pivot('pivot_name')
            ->run()
            ->withReport();

$diff->tables('base_table','merge_table')
    ->pivot('id')
    ->column('column_to_update')
    ->merge();

diff->tables('base_table','merge_table')
    ->pivot('id')
    ->column('column_to_update')
    ->mergeMatched();

diff->tables('base_table','merge_table')
    ->pivot('id')
    ->column('column_to_update')
    ->mergeUnMatched();

$ddiff->tables('base_table','merge_table')
            ->pivot('id')
            ->column('column_to_update')
            ->merge(null,function(&$data){
                // HERE your code
                $data->column_to_update = (float) $data->column_to_update;
            });

$diff->tables('base_table','merge_table')
    ->pivot('id')
    ->column('column_to_update')
    ->merge(function($collection,$data){
        //HERE your code
    });

$diff->tables('base_table','merge_table')
    ->pivot('id')
    ->column('column_to_update')
    ->mergeUnMatched(function($list){
        //HERE your code
    });

$diff->eventPayload(['user' => 'John Doe']);

'providers' => array(
        ...
        Edujugon\TableDiff\Providers\TableDiffServiceProvider::class
    )

'aliases' => array(
        ...
        'TableDiff' => Edujugon\TableDiff\Facades\TableDiff::class,
    )