Skip to content

Commit

Permalink
Initial construction
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Johnson committed Dec 16, 2015
1 parent 71a4bcd commit af1a4a0
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/bootstrap/compiled.php
.env.*.php
.env.php
.env
/vendor
composer.phar
composer.lock
.DS_Store
.idea/
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "aejnsn/laravel-pgsql-types",
"description": "Extended PostgreSQL Types for Laravel",
"keywords": ["postgresql", "pgsql", "laravel", "types"],
"license": "MIT",
"authors": [
{
"name": "Aaron Johnson",
"email": "[email protected]"
}
],
"minimum-stability": "stable",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
}
}
20 changes: 20 additions & 0 deletions src/DatabaseServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Aejnsn\LaravelPgsqlTypes;

use Illuminate\Database\Connectors\ConnectionFactory;
use Illuminate\Database\DatabaseServiceProvider as BaseDatabaseServiceProvider;

class DatabaseServiceProvider extends BaseDatabaseServiceProvider
{
public function register()
{
$this->app->singleton('db.factory', function ($app) {
return new ConnectionFactory($app);
});

$this->app->singleton('db.factory', function ($app) {
return new DatabaseManager($app, $app['db.factory']);
});
}
}
29 changes: 29 additions & 0 deletions src/PostgresConnection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Aejnsn\LaravelPgsqlTypes;

use Aejnsn\LaravelPgsqlTypes\Schema\Builder as SchemaBuilder;
use Aejnsn\LaravelPgsqlTypes\Schema\Grammars\PostgresGrammar as AejnsnPostgresGrammar;
use Illuminate\Database\PostgresConnection as BasePostgresConnection;
use Illuminate\Database\Query\Processors\PostgresProcessor;

class PostgresConnection extends BasePostgresConnection
{
public function getSchemaBuilder()
{
if (is_null($this->schemaGrammar)) {
$this->useDefaultSchemaGrammar();
}
return new SchemaBuilder($this);
}

protected function getDefaultSchemaGrammar()
{
return $this->withTablePrefix(new AejnsnPostgresGrammar);
}

protected function getDefaultPostProcessor()
{
return new PostgresProcessor;
}
}
43 changes: 43 additions & 0 deletions src/Schema/Blueprint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Aejnsn\LaravelPgsqlTypes\Schema\Grammars;

use Illuminate\Database\Schema\Blueprint as BaseBlueprint;

class Blueprint extends BaseBlueprint
{
protected function addFluentIndexes()
{
foreach ($this->columns as $column) {
foreach (['primary', 'unique', 'index'] as $index) {
if ($column->$index === true) {
$this->$index($column->name);
continue 2;
} elseif (isset($column->$index)) {
$this->$index($column->name, $column->$index);
continue 2;
}
}
}
}

public function inet($column)
{
return $this->addColumn('inet', $column);
}

public function point($column)
{
return $this->addColumn('point', $column);
}

public function money($column)
{
return $this->addColumn('money', $column);
}

public function dateRange($column)
{
return $this->addColumn('daterange', $column);
}
}
8 changes: 8 additions & 0 deletions src/Schema/Builder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Aejnsn\LaravelPgsqlTypes\Schema;

class Builder extends Illuminate\Database\Schema\Builder
{

}
10 changes: 10 additions & 0 deletions src/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Aejnsn\LaravelPgsqlTypes\Schema\Grammars;

use Illuminate\Database\Grammar;

class PostgresGrammar extends Grammar
{

}

0 comments on commit af1a4a0

Please sign in to comment.