Skip to content

Commit af1a4a0

Browse files
author
Aaron Johnson
committed
Initial construction
1 parent 71a4bcd commit af1a4a0

File tree

7 files changed

+135
-4
lines changed

7 files changed

+135
-4
lines changed

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/bootstrap/compiled.php
2-
.env.*.php
3-
.env.php
4-
.env
1+
/vendor
2+
composer.phar
3+
composer.lock
4+
.DS_Store
5+
.idea/

composer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "aejnsn/laravel-pgsql-types",
3+
"description": "Extended PostgreSQL Types for Laravel",
4+
"keywords": ["postgresql", "pgsql", "laravel", "types"],
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Aaron Johnson",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"minimum-stability": "stable",
13+
"require": {
14+
"php": ">=5.5.9",
15+
"laravel/framework": "5.1.*"
16+
},
17+
"require-dev": {
18+
"phpunit/phpunit": "~4.0"
19+
}
20+
}

src/DatabaseServiceProvider.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Aejnsn\LaravelPgsqlTypes;
4+
5+
use Illuminate\Database\Connectors\ConnectionFactory;
6+
use Illuminate\Database\DatabaseServiceProvider as BaseDatabaseServiceProvider;
7+
8+
class DatabaseServiceProvider extends BaseDatabaseServiceProvider
9+
{
10+
public function register()
11+
{
12+
$this->app->singleton('db.factory', function ($app) {
13+
return new ConnectionFactory($app);
14+
});
15+
16+
$this->app->singleton('db.factory', function ($app) {
17+
return new DatabaseManager($app, $app['db.factory']);
18+
});
19+
}
20+
}

src/PostgresConnection.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Aejnsn\LaravelPgsqlTypes;
4+
5+
use Aejnsn\LaravelPgsqlTypes\Schema\Builder as SchemaBuilder;
6+
use Aejnsn\LaravelPgsqlTypes\Schema\Grammars\PostgresGrammar as AejnsnPostgresGrammar;
7+
use Illuminate\Database\PostgresConnection as BasePostgresConnection;
8+
use Illuminate\Database\Query\Processors\PostgresProcessor;
9+
10+
class PostgresConnection extends BasePostgresConnection
11+
{
12+
public function getSchemaBuilder()
13+
{
14+
if (is_null($this->schemaGrammar)) {
15+
$this->useDefaultSchemaGrammar();
16+
}
17+
return new SchemaBuilder($this);
18+
}
19+
20+
protected function getDefaultSchemaGrammar()
21+
{
22+
return $this->withTablePrefix(new AejnsnPostgresGrammar);
23+
}
24+
25+
protected function getDefaultPostProcessor()
26+
{
27+
return new PostgresProcessor;
28+
}
29+
}

src/Schema/Blueprint.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Aejnsn\LaravelPgsqlTypes\Schema\Grammars;
4+
5+
use Illuminate\Database\Schema\Blueprint as BaseBlueprint;
6+
7+
class Blueprint extends BaseBlueprint
8+
{
9+
protected function addFluentIndexes()
10+
{
11+
foreach ($this->columns as $column) {
12+
foreach (['primary', 'unique', 'index'] as $index) {
13+
if ($column->$index === true) {
14+
$this->$index($column->name);
15+
continue 2;
16+
} elseif (isset($column->$index)) {
17+
$this->$index($column->name, $column->$index);
18+
continue 2;
19+
}
20+
}
21+
}
22+
}
23+
24+
public function inet($column)
25+
{
26+
return $this->addColumn('inet', $column);
27+
}
28+
29+
public function point($column)
30+
{
31+
return $this->addColumn('point', $column);
32+
}
33+
34+
public function money($column)
35+
{
36+
return $this->addColumn('money', $column);
37+
}
38+
39+
public function dateRange($column)
40+
{
41+
return $this->addColumn('daterange', $column);
42+
}
43+
}

src/Schema/Builder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Aejnsn\LaravelPgsqlTypes\Schema;
4+
5+
class Builder extends Illuminate\Database\Schema\Builder
6+
{
7+
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Aejnsn\LaravelPgsqlTypes\Schema\Grammars;
4+
5+
use Illuminate\Database\Grammar;
6+
7+
class PostgresGrammar extends Grammar
8+
{
9+
10+
}

0 commit comments

Comments
 (0)