asmiarowski/laravel-postgres 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

asmiarowski/laravel-postgres

最新稳定版本:v0.1.4

Composer 安装命令:

composer require asmiarowski/laravel-postgres

包简介

Eloquent support for postgreSQL fields

README 文档

README

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>

统计信息

  • 总下载量: 38.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 2
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固