PHPackages                             johdougss/laravel-mass-update - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. johdougss/laravel-mass-update

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

johdougss/laravel-mass-update
=============================

1.0.1(2y ago)16PHP

Since Jul 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/johdougss/laravel-mass-update)[ Packagist](https://packagist.org/packages/johdougss/laravel-mass-update)[ RSS](/packages/johdougss-laravel-mass-update/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Mass Update
===========

[](#mass-update)

Postgres mass update.

This query is used to bulk update in PostgreSQL. You can use this query to update multiple rows at once.

```
update "transactions" as "t"
set "value" = "m"."value"::decimal
from (values (1, 10), (2, 20), (3, 30)) as "m" (id, value)
where "m"."id"::bigint = "t"."id"
```

Added a new `joinFrom` method in the query builder to simplify the sql build.

Install
=======

[](#install)

```
composer require johdougss/laravel-mass-update

```

configure in app.php

```
'providers' => ServiceProvider::defaultProviders()->merge([
    ...

    Johdougss\Database\DatabaseMassUpdateServiceProvider::class,
])->toArray(),

```

Usage
=====

[](#usage)

`joinFrom`

```
DB::table('transactions as t')
    ->joinFrom([['id' => 1, 'value' => 10], ['id' => 2, 'value' => 20]], 'm', DB::raw('m.id::bigint'), '=', 't.id')
    ->updateFrom([
        'value' => DB::raw('m.value::decimal'),
    ]);
```

### Example 1:

[](#example-1)

create migration

```
Schema::create('transactions', function (Blueprint $table) {
    $table->id();
    $table->decimal('value', 12, 2);
    $table->integer('type')->default(1);
    $table->string('status', 10)->default('pending');
    $table->timestamp('date');
    $table->timestamps();
});
```

from values with `join` laravel

```
 $values = [
    [
        'id' => 1,
        'value' => 20,
    ],
    [
        'id' => 2,
        'value' => 30,
    ],
     [
        'id' => 3,
        'value' => 30,
    ],
];

DB::table('transactions as t')
    ->join(DB::raw('(values (1,10), (2, 20), (3, 30) ) as mu (id, value, date)'), 'mu.id', '=', 't.id')
    ->updateFrom([
        'value' => DB::raw('(mu.value::decimal + 1)::decimal'),
        'date' => DB::raw('mu.date::timestamp'),
        'type' => 2,
        'status' => DB::raw('case t.id when 1 then \'paid\' else t.status end'),
]);
```

from values with `joinFrom` laravel

```
 $values = [
    [
        'id' => 1,
        'value' => 20,
    ],
    [
        'id' => 2,
        'value' => 30,
    ],
     [
        'id' => 3,
        'value' => 30,
    ],
];

DB::table('transactions as t')
    ->joinFrom($values, 'm', DB::raw('m.id::bigint'), '=', 't.id')
    ->updateFrom([
        'value' => DB::raw('m.value::decimal'),
    ]);
```

Output SQL

```
update "transactions" as "t"
set "value" = m.value::decimal
from (values (?, ?), (?, ?), (?, ?)) as m (id, value)
where m.id::bigint = "t"."id"
```

Debug:

```
array:1 [
  0 => array:3 [
    "query" => "update "transactions" as "t" set "value" = m.value::decimal from (values (?, ?), (?, ?), (?, ?)) as m (id, value) where m.id::bigint = "t"."id""
    "bindings" => array:6 [
      0 => 1
      1 => 20
      2 => 2
      3 => 30
      4 => 3
      5 => 30
    ]
    "time" => 2.5
  ]
]
```

### Example 2:

[](#example-2)

```
 $values = [
    [
        'id' => 1,
        'date' => Carbon::now(),
        'value' => 20,
    ],
    [
        'id' => 2,
        'date' => '2023-01-02',
        'value' => 30,
    ],
];

DB::table('transactions as t')
    ->joinFrom($values, 'm', DB::raw('m.id::bigint'), '=', 't.id')
    ->updateFrom([
        'value' => DB::raw('(m.value::decimal + 1)::decimal'),
        'date' => DB::raw('m.date::timestamp'),
        'type' => 2,
        'status' => DB::raw('case t.id when 1 then \'paid\' else t.status end'),
    ]);
```

Output SQL

```
update "transactions" as "t"
set "value" = (m.value::decimal + 1)::decimal,
    "date"   = m.date::timestamp,
    "type"   = ?,
    "status" = case t.id when 1 then 'paid' else t.status
end
from (values (?, ?, ?), (?, ?, ?)) as m (id, date, value)
where m.id::bigint = "t"."id"
```

Debug:

```
array:1 [
  0 => array:3 [
    "query" => "update "transactions" as "t" set "value" = (m.value::decimal + 1)::decimal, "date" = m.date::timestamp, "type" = ?, "status" = case t.id when 1 then 'paid' else t.status end from (values (?, ?, ?), (?, ?, ?)) as m (id, date, value) where m.id::bigint = "t"."id""
    "bindings" => array:7 [
      0 => 2
      1 => 1
      2 => Carbon\Carbon @1689177399^ {#817
        ...
        date: 2023-07-12 15:56:39.887268 UTC (+00:00)
      }
      3 => 20
      4 => 2
      5 => "2023-01-02"
      6 => 30
    ]
    "time" => 6.6
  ]
]
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

2

Last Release

1034d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4b8cb9ec4c94d8a877f45815400dffdec11ad705304d4560fae317a770607bf?d=identicon)[johdougss](/maintainers/johdougss)

---

Top Contributors

[![johdougss](https://avatars.githubusercontent.com/u/1482660?v=4)](https://github.com/johdougss "johdougss (6 commits)")

### Embed Badge

![Health badge](/badges/johdougss-laravel-mass-update/health.svg)

```
[![Health](https://phpackages.com/badges/johdougss-laravel-mass-update/health.svg)](https://phpackages.com/packages/johdougss-laravel-mass-update)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[efureev/laravel-trees

Multi-Tree structures for Laravel

14253.3k4](/packages/efureev-laravel-trees)[illuminatech/balance

Provides support for Balance accounting system based on debit and credit principle

16137.4k](/packages/illuminatech-balance)[zonneplan/laravel-module-loader

Module loader for Laravel

24118.4k](/packages/zonneplan-laravel-module-loader)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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