PHPackages                             edujugon/tablediff - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. edujugon/tablediff

ActiveLibrary[Database &amp; ORM](/categories/database)

edujugon/tablediff
==================

Comparing DB tables data for Laravel

1.0.9(8y ago)31772MITPHP

Since Jun 5Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Edujugon/tablediff)[ Packagist](https://packagist.org/packages/edujugon/tablediff)[ RSS](/packages/edujugon-tablediff/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (5)Versions (12)Used By (0)

TableDiff
=========

[](#tablediff)

Comparing DB tables data for Laravel.

Installation
------------

[](#installation)

type in console:

```
composer require edujugon/tablediff

```

Register TableDiff service by adding it to the providers array.

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

```

Let's add the Alias facade, add it to the aliases array.

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

```

Usage samples
-------------

[](#usage-samples)

Instance the main TableDiff class:

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

Add tables to be compared

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

Set the pivots

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

If the columns have the same name you could do it like follows:

```
$diff->pivot('pivot_name');
```

Now, we can run the comparison and get the report

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

Of course, all those methods can be chained

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

> Notice if you don't use `column` method, it will look for all columns with same name in both tables.

### Merging

[](#merging)

The simplest way yo do a merge is like follows

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

The above code snippet will update the `column_to_update` column values from base\_table with the `column_to_update` column values of merge\_table in matched ids.

> Notice that `merge` method will update the matched records and also add those records that are new for base table.

Just merging matched records

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

Now, let's insert the new records.

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

`merge`, `mergeMatched` and `mergeUnMatched` methods accept callbacks before doing the merge and just after each update.

Before callback is perfect for casting data like. It takes the data which will be added.

```
$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;
            });
```

The first callback is call each time the db is updated. It takes the collection to be updated and the data with the new values

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

In case of `mergeUnMatched`, the first callback takes the new elements to be added and is called for each chunk (By default 10)

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

#### Event

[](#event)

Once the merge is done the package fires an event call `Edujugon\TableDiff\Events\MergeDone` with some useful parameters

Parameters:

- Merge type
- Report
- Extra payload

Extra payload can be anything you want to add the the event

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

> Kepp in mind that `eventPayload` method have to be called before calling `merge` method.

That is perfect when need to do some actions after merging like store it in db, send notification, etc..

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 98% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

10

Last Release

3240d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2806ab557e2a153347da9fb0e2dbe58ab47ce10bb60ccac71193e8ed67349a23?d=identicon)[edujugon](/maintainers/edujugon)

---

Top Contributors

[![Edujugon](https://avatars.githubusercontent.com/u/4853751?v=4)](https://github.com/Edujugon "Edujugon (49 commits)")[![alrik11es](https://avatars.githubusercontent.com/u/249844?v=4)](https://github.com/alrik11es "alrik11es (1 commits)")

---

Tags

laravel-5-packagelaravel-packagetabledifflaravelpackagedifferencestableDiff

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/edujugon-tablediff/health.svg)

```
[![Health](https://phpackages.com/badges/edujugon-tablediff/health.svg)](https://phpackages.com/packages/edujugon-tablediff)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8703.0M17](/packages/yajra-laravel-oci8)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
