New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

asmiarowski/laravel-postgres

Eloquent support for postgreSQL fields
38,407 15
Install
composer require asmiarowski/laravel-postgres
Latest Version:v0.1.4
PHP:>=5.5.9
Laravel:5
License:MIT
Last Updated:May 12, 2016
Links: GitHub  ·  Packagist
Maintainer: asmiarowski

laravel-postgres

Adds support for postgreSQL fields for Eloquent.

Installation

``` composer require asmiarowski/laravel-postgres ```

Array field

Add trait to your model:

``` use Illuminate\Database\Eloquent\Model; use Smiarowski\Postgres\Model\Traits\PostgresArray;

class ExampleModel extends Model { use PostgresArray; }

<p>Set up accessor and mutator for your array field like so:</p>

public function setArrayField(array $value) { $this->array_field = self::mutateToPgArray($value); } public function getArrayField() { return self::accessPgArray($this->array_field); }

<p>Query scopes available for builder:</p>
<p><b>wherePgArrayContains(string $column, mixed $value)</b>: Adds where query part, $column has all of the elements in $value. $value can be array, integer or string</p>
<p><b>wherePgArrayOverlap(string $column, mixed $value)</b>: Adds where query part, $column has any (at least one) of the elements in $value. $value can be array, integer or string</p>

<p>For example, let's say you have an array of strings as tags for restaurants. If you would want to find all restaurants that serve pizza or lasagne, you would build your query like so:</p>

$restaurants = Restaurant::wherePgArrayOverlap('tag', ['pizza', 'lasagne'])->get();

<p>Above example would return only thoes restaurants that have tags pizza <b>or</b> lasagne in their defined tags field. If you would want only restaurants that have all of the tags specified, you would use <b>wherePgArrayContains</b> instead.</p>

Related Packages

t1nkl/postgres-pgbouncer-extension

Laravel PostgreSQL pgbouncer extension fix for PDO::ATTR_EMULATE_PREPARES option

286,185 9
lionmm/laravel-pgbouncer-extension

Laravel PostgreSQL pgbouncer extension fix for PDO::ATTR_EMULATE_PREPARES option

5,761 0
tpetry/laravel-postgresql-enhanced

Support for many missing PostgreSQL specific features

3,171,362 1,042
symfony/ai-postgres-store

PostgreSQL pgvector vector store bridge for Symfony AI

76,364 2
pacuna/schemas

Laravel package for managing postgresql schemas

66,032 41

Version History

Version Released PHP Laravel License
v0.1.4 >=5.5.9 ^5.2 MIT
v0.1.3 >=5.5.9 ^5.2 MIT
v0.1.2 >=5.5.9 ^5.2 MIT
v0.1.1 >=5.5.9 ^5.2 MIT
v0.1.0 >=5.5.9 ^5.2 MIT