PHPackages                             ishifoev/laravel-extended-grammars - 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. ishifoev/laravel-extended-grammars

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

ishifoev/laravel-extended-grammars
==================================

Extends Laravel's database grammars with advanced SQL helpers like insertOrUpdateUsing().

1.0.1(8mo ago)25MITPHPPHP ^8.1|^8.2|^8.3

Since Oct 17Pushed 8mo agoCompare

[ Source](https://github.com/ishifoev/laravel-extended-grammars)[ Packagist](https://packagist.org/packages/ishifoev/laravel-extended-grammars)[ RSS](/packages/ishifoev-laravel-extended-grammars/feed)WikiDiscussions main Synced today

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

Laravel Extended Grammars
=========================

[](#laravel-extended-grammars)

[![Packagist Version](https://camo.githubusercontent.com/b2a1413bafafa86f7d7b56ca4fa773818acbe4d92a8496e5fb304c57f08c12ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69736869666f65762f6c61726176656c2d657874656e6465642d6772616d6d6172733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ishifoev/laravel-extended-grammars)[![Packagist Downloads](https://camo.githubusercontent.com/f53124eb08db65143ef9e9869c987b53d876b16d04d39d45138b285eeaa2d4e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69736869666f65762f6c61726176656c2d657874656e6465642d6772616d6d6172733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ishifoev/laravel-extended-grammars)[![License](https://camo.githubusercontent.com/31113230376ec73fdbaf2640bdb26d9e65f76768aa60a4f86a961ebcad62ff4a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f69736869666f65762f6c61726176656c2d657874656e6465642d6772616d6d6172733f7374796c653d666c61742d737175617265)](LICENSE)

> 🧩 Extends Laravel's database grammars with advanced SQL helpers like `insertOrUpdateUsing()` for MySQL, PostgreSQL, and SQLite.

---

🚀 Installation
--------------

[](#-installation)

```
composer require ishifoev/laravel-extended-grammars
```

🧠 Example: Query Builder
------------------------

[](#-example-query-builder)

```
DB::table('users')->insertOrUpdateUsing(
    ['id', 'name', 'email'], // columns to insert
    DB::table('imports')->select('id', 'name', 'email'), // source data
    ['name', 'email'] // columns to update if duplicate
);
```

Generated SQL (MySQL):
----------------------

[](#generated-sql-mysql)

```
INSERT INTO users (id, name, email)
SELECT id, name, email FROM imports
ON DUPLICATE KEY UPDATE
    name = VALUES(name),
    email = VALUES(email);
```

PostgreSQL:
-----------

[](#postgresql)

```
INSERT INTO users (id, name, email)
SELECT id, name, email FROM imports
ON CONFLICT (id) DO UPDATE SET
    name = EXCLUDED.name,
    email = EXCLUDED.email;
```

SQLite
------

[](#sqlite)

```
INSERT INTO users (id, name, email)
SELECT id, name, email FROM imports
ON CONFLICT(id) DO UPDATE SET
    name = excluded.name,
    email = excluded.email;
```

🧩 Example: Eloquent Model
-------------------------

[](#-example-eloquent-model)

```
use App\Models\User;

User::insertOrUpdateUsing(
    ['id', 'name', 'email'],
    DB::table('imports')->select('id', 'name', 'email'),
    ['name', 'email']
);
```

Supported
---------

[](#supported)

DatabaseStatusLaravel VersionsMySQL✅ Full support10, 11, 12PostgreSQL✅ Full support10, 11, 12SQLite✅ Full support10, 11, 12🧪 Testing
---------

[](#-testing)

Install dependencies:

```
composer install

```

Run all checks:

```
composer test
composer lint
composer analyze

```

Or run via Docker:

```
docker-compose run --rm test

```

🧰 Composer Scripts
------------------

[](#-composer-scripts)

CommandDescription`composer test`Run PHPUnit tests`composer lint`Check code style via Laravel Pint`composer analyze`Run static analysis via Psalm🧱 Project Structure
-------------------

[](#-project-structure)

```
src/
 ├── Concerns/SupportsInsertOrUpdateUsing.php
 ├── Contracts/InsertOrUpdateGrammarInterface.php
 ├── Factories/GrammarFactory.php
 ├── Grammars/
 │   ├── MySqlGrammar.php
 │   ├── PostgresGrammar.php
 │   └── SQLiteGrammar.php
 └── Providers/ExtendedGrammarsServiceProvider.php
tests/
 ├── MySqlGrammarTest.php
 ├── PostgresGrammarTest.php
 └── SQLiteGrammarTest.php
```

🧑‍💻 Author
----------

[](#‍-author)

**Ismoil Shifoev**

*Senior Laravel Developer*

📧

🪪 License

Licensed under the MIT License

Copyright (c) 2025 Ismoil Shifoev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

🏷️ Version History

**v1.0.0 (Initial Release)**

Added MySQL/PostgreSQL/SQLite support

Added insertOrUpdateUsing() for models and Query Builder

Added unit tests and static analysis

Added Laravel Pint and Psalm integration

Laravel 10, 11, 12 compatible

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance59

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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

Unknown

Total

1

Last Release

261d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/90cf56bb60a2395a6f8c61ae3ee3b41193bda2cd21049e0e7cbed3385233da7a?d=identicon)[AlexMalikov94](/maintainers/AlexMalikov94)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ishifoev-laravel-extended-grammars/health.svg)

```
[![Health](https://phpackages.com/badges/ishifoev-laravel-extended-grammars/health.svg)](https://phpackages.com/packages/ishifoev-laravel-extended-grammars)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k32.6M46](/packages/kirschbaum-development-eloquent-power-joins)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[awobaz/compoships

Laravel relationships with support for composite/multiple keys

1.2k11.7M46](/packages/awobaz-compoships)[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.3M19](/packages/bavix-laravel-wallet)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)

PHPackages © 2026

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