PHPackages                             emiliopedrollo/laravel-postgres-extended-schema - 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. emiliopedrollo/laravel-postgres-extended-schema

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

emiliopedrollo/laravel-postgres-extended-schema
===============================================

Eloquent Extended, added some PostgreSQL features

v5.0.2(9mo ago)05.7k2MITPHPPHP ^8.0.2

Since Feb 14Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/emiliopedrollo/laravel-postgres-extended-schema)[ Packagist](https://packagist.org/packages/emiliopedrollo/laravel-postgres-extended-schema)[ RSS](/packages/emiliopedrollo-laravel-postgres-extended-schema/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (54)Used By (0)

Laravel Postgres Extended
=========================

[](#laravel-postgres-extended)

[![Build Status](https://camo.githubusercontent.com/17cf7045f30cf67d2b6163d659e2ba5429aa2c4385d46843ac52364a6d0f5f7d/68747470733a2f2f7472617669732d63692e6f72672f656d696c696f706564726f6c6c6f2f6c61726176656c2d706f7374677265732d657874656e6465642d736368656d612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/emiliopedrollo/laravel-postgres-extended-schema)[![Maintainability](https://camo.githubusercontent.com/ebccbf3c166a0b5a8dde9d6a624081525c19c7702f8dee3c120c943490f4df1c/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f35633036666135326530306466643564303564302f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/emiliopedrollo/laravel-postgres-extended-schema/maintainability)[![Latest Stable Version](https://camo.githubusercontent.com/1e54b214a212b9c94f07fc571491a7205e4288a481d6360a06e37a2276aaa664/68747470733a2f2f706f7365722e707567782e6f72672f656d696c696f706564726f6c6c6f2f6c61726176656c2d706f7374677265732d657874656e6465642d736368656d612f762f737461626c65)](https://packagist.org/packages/emiliopedrollo/laravel-postgres-extended-schema)[![Total Downloads](https://camo.githubusercontent.com/e795b81f010a24f0d77fbfd91e4e079131eb7acb22513c886a2ae89bc7c80d25/68747470733a2f2f706f7365722e707567782e6f72672f656d696c696f706564726f6c6c6f2f6c61726176656c2d706f7374677265732d657874656e6465642d736368656d612f646f776e6c6f616473)](https://packagist.org/packages/emiliopedrollo/laravel-postgres-extended-schema)[![Monthly Downloads](https://camo.githubusercontent.com/b4bf7d10929a3d5c8901cd38575ca8a213e365ac560d41d65198e327f3f9008f/68747470733a2f2f706f7365722e707567782e6f72672f656d696c696f706564726f6c6c6f2f6c61726176656c2d706f7374677265732d657874656e6465642d736368656d612f642f6d6f6e74686c79)](https://packagist.org/packages/emiliopedrollo/laravel-postgres-extended-schema)[![License](https://camo.githubusercontent.com/899355c9b257b2f153231548c015e9dccc680d00b9da8aff593a7c32b7667b8c/68747470733a2f2f706f7365722e707567782e6f72672f656d696c696f706564726f6c6c6f2f6c61726176656c2d706f7374677265732d657874656e6465642d736368656d612f6c6963656e7365)](https://packagist.org/packages/emiliopedrollo/laravel-postgres-extended-schema)[![License](https://camo.githubusercontent.com/899355c9b257b2f153231548c015e9dccc680d00b9da8aff593a7c32b7667b8c/68747470733a2f2f706f7365722e707567782e6f72672f656d696c696f706564726f6c6c6f2f6c61726176656c2d706f7374677265732d657874656e6465642d736368656d612f6c6963656e7365)](https://packagist.org/packages/emiliopedrollo/laravel-postgres-extended-schema)

Introduction
------------

[](#introduction)

An extended PostgreSQL driver for Laravel 9+ with support for some aditional PostgreSQL data types: hstore, uuid, geometric types (point, path, circle, line, polygon...) and support for WITH \[RECURSIVE\] clause

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

[](#installation)

Simple run `composer require emiliopedrollo/laravel-postgres-extended-schema` in your project root directory.

Then you are done.

Usage
-----

[](#usage)

- [SELECT Queries](#select-queries)
- [INSERT/UPDATE/DELETE Queries](#insertupdatedelete-queries)
- [Eloquent](#eloquent)
    - [Recursive Relationships](#recursive-relationships)

### SELECT Queries

[](#select-queries)

Use `withExpression()` and provide a query builder instance, an SQL string or a closure:

```
$posts = DB::table('p')
    ->select('p.*', 'u.name')
    ->withExpression('p', DB::table('posts'))
    ->withExpression('u', function ($query) {
        $query->from('users');
    })
    ->join('u', 'u.id', '=', 'p.user_id')
    ->get();
```

Use `withRecursiveExpression()` for recursive expressions:

```
$query = DB::table('users')
    ->whereNull('parent_id')
    ->unionAll(
        DB::table('users')
            ->select('users.*')
            ->join('tree', 'tree.id', '=', 'users.parent_id')
    );

$tree = DB::table('tree')
    ->withRecursiveExpression('tree', $query)
    ->get();
```

You can provide the expression's columns as the third argument:

```
$query = 'select 1 union all select number + 1 from numbers where number < 10';

$numbers = DB::table('numbers')
    ->withRecursiveExpression('numbers', $query, ['number'])
    ->get();
```

### INSERT/UPDATE/DELETE Queries

[](#insertupdatedelete-queries)

You can use common table expressions in `INSERT`, `UPDATE` and `DELETE` queries:

```
DB::table('profiles')
    ->withExpression('u', DB::table('users')->select('id', 'name'))
    ->insertUsing(['user_id', 'name'], DB::table('u'));
```

```
DB::table('profiles')
    ->withExpression('u', DB::table('users'))
    ->join('u', 'u.id', '=', 'profiles.user_id')
    ->update(['profiles.name' => DB::raw('u.name')]);
```

```
DB::table('profiles')
    ->withExpression('u', DB::table('users')->where('active', false))
    ->whereIn('user_id', DB::table('u')->select('id'))
    ->delete();
```

### Eloquent

[](#eloquent)

You can use common table expressions in Eloquent queries.

```
$query = User::whereNull('parent_id')
    ->unionAll(
        User::select('users.*')
            ->join('tree', 'tree.id', '=', 'users.parent_id')
    );

$tree = User::from('tree')
    ->withRecursiveExpression('tree', $query)
    ->get();
```

#### Recursive Relationships

[](#recursive-relationships)

If you want to implement recursive relationships, you can use this package: [staudenmeir/laravel-adjacency-list](https://github.com/staudenmeir/laravel-adjacency-list)

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance57

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~75 days

Recently: every ~99 days

Total

52

Last Release

287d ago

Major Versions

0.19 → v1.0.02019-11-11

v1.2.3 → v2.0.02019-11-20

v2.9.0 → v3.0.02023-03-27

v3.1.1 → v4.11.02024-06-28

v4.11.1 → v5.0.02025-07-24

PHP version history (7 changes)0.1PHP &gt;=5.4.0

0.11PHP &gt;=5.4

0.19PHP &gt;=5.6

v1.0.0PHP &gt;=7.2

v2.2.0PHP ^7.3

v2.5.0PHP ^7.3|^8.0

v3.0.0PHP ^8.0.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/442cd299d4ec476168c0d4274a4f2f784573c61d27a0a955067bc05233bbcec5?d=identicon)[emiliopedrollo](/maintainers/emiliopedrollo)

---

Top Contributors

[![emiliopedrollo](https://avatars.githubusercontent.com/u/6577541?v=4)](https://github.com/emiliopedrollo "emiliopedrollo (67 commits)")[![mirzap](https://avatars.githubusercontent.com/u/991967?v=4)](https://github.com/mirzap "mirzap (61 commits)")[![phaza](https://avatars.githubusercontent.com/u/4553?v=4)](https://github.com/phaza "phaza (9 commits)")[![gueroverde](https://avatars.githubusercontent.com/u/1765489?v=4)](https://github.com/gueroverde "gueroverde (7 commits)")[![howlowck](https://avatars.githubusercontent.com/u/338265?v=4)](https://github.com/howlowck "howlowck (4 commits)")[![zakhenry](https://avatars.githubusercontent.com/u/721513?v=4)](https://github.com/zakhenry "zakhenry (3 commits)")[![dvmuccillo](https://avatars.githubusercontent.com/u/6137203?v=4)](https://github.com/dvmuccillo "dvmuccillo (2 commits)")[![olegmelnik](https://avatars.githubusercontent.com/u/7072397?v=4)](https://github.com/olegmelnik "olegmelnik (1 commits)")[![pelim](https://avatars.githubusercontent.com/u/624330?v=4)](https://github.com/pelim "pelim (1 commits)")[![rap2hpoutre](https://avatars.githubusercontent.com/u/1575946?v=4)](https://github.com/rap2hpoutre "rap2hpoutre (1 commits)")[![jimmypuckett](https://avatars.githubusercontent.com/u/3220069?v=4)](https://github.com/jimmypuckett "jimmypuckett (1 commits)")[![gbuckingham89](https://avatars.githubusercontent.com/u/1455253?v=4)](https://github.com/gbuckingham89 "gbuckingham89 (1 commits)")[![gilbertorussi](https://avatars.githubusercontent.com/u/33965697?v=4)](https://github.com/gilbertorussi "gilbertorussi (1 commits)")[![hotmeteor](https://avatars.githubusercontent.com/u/378585?v=4)](https://github.com/hotmeteor "hotmeteor (1 commits)")[![deadem](https://avatars.githubusercontent.com/u/7988931?v=4)](https://github.com/deadem "deadem (1 commits)")[![martinnaughton](https://avatars.githubusercontent.com/u/4721428?v=4)](https://github.com/martinnaughton "martinnaughton (1 commits)")[![masunov](https://avatars.githubusercontent.com/u/1958751?v=4)](https://github.com/masunov "masunov (1 commits)")

---

Tags

laraveldatabasepostgresqleloquent

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/emiliopedrollo-laravel-postgres-extended-schema/health.svg)

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[bosnadev/database

Eloquent Extended, added some PostgreSQL features

811.8M3](/packages/bosnadev-database)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[pdphilip/elasticsearch

An Elasticsearch implementation of Laravel's Eloquent ORM

145360.2k4](/packages/pdphilip-elasticsearch)[mvanduijker/laravel-transactional-model-events

Add eloquent model events fired after a transaction is committed or rolled back

75164.5k](/packages/mvanduijker-laravel-transactional-model-events)

PHPackages © 2026

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