2017 © Pedro Peláez
 

library laravel-postgres

Eloquent support for postgreSQL fields

image

asmiarowski/laravel-postgres

Eloquent support for postgreSQL fields

  • Thursday, May 12, 2016
  • by asmiarowski
  • Repository
  • 1 Watchers
  • 8 Stars
  • 8,780 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 6 Versions
  • 12 % Grown

The README.md

laravel-postgres

Adds support for postgreSQL fields for Eloquent., (*1)

Installation

composer require asmiarowski/laravel-postgres

Array field

Add trait to your model:, (*2)

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

class ExampleModel extends Model
{
    use PostgresArray;
}

, (*3)

Set up accessor and mutator for your array field like so:, (*4)

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

Query scopes available for builder:, (*5)

wherePgArrayContains(string $column, mixed $value): Adds where query part, $column has all of the elements in $value. $value can be array, integer or string, (*6)

wherePgArrayOverlap(string $column, mixed $value): Adds where query part, $column has any (at least one) of the elements in $value. $value can be array, integer or string, (*7)

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:, (*8)

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

Above example would return only thoes restaurants that have tags pizza or lasagne in their defined tags field. If you would want only restaurants that have all of the tags specified, you would use wherePgArrayContains instead., (*9)

The Versions

12/05 2016

dev-master

9999999-dev

Eloquent support for postgreSQL fields

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artur Śmiarowski

laravel postgresql postgres

18/04 2016

v0.1.4

0.1.4.0

Eloquent support for postgreSQL fields

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artur Śmiarowski

laravel postgresql postgres

11/04 2016

v0.1.3

0.1.3.0

Eloquent support for postgreSQL fields

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artur Śmiarowski

laravel postgresql postgres

26/12 2015

v0.1.2

0.1.2.0

Eloquent support for postgreSQL fields

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artur Śmiarowski

laravel postgresql postgres

26/12 2015

v0.1.1

0.1.1.0

Eloquent support for postgreSQL fields

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artur Śmiarowski

laravel postgresql postgres

26/12 2015

v0.1.0

0.1.0.0

Eloquent support for postgreSQL fields

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artur Śmiarowski

laravel postgresql postgres