-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadDB.php
44 lines (41 loc) · 1.36 KB
/
loadDB.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require __DIR__ . '/vendor/autoload.php';
class DB extends Illuminate\Support\Facades\Facade
{
protected static function getFacadeAccessor()
{
if (!isset(self::$resolvedInstance['db'])) {
$dbConfig = [
'driver' => getenv('DB_DRIVER'),
'host' => getenv('DB_HOST'),
'port' => getenv('DB_PORT'),
'database' => getenv('DB_DATABASE'),
'modes' => [],
'username' => getenv('DB_USERNAME'),
'password' => getenv('DB_PASSWORD'),
'charset' => getenv('DB_CHARSET'),
'collation' => getenv('DB_COLLATION'),
'prefix' => getenv('DB_PREFIX'),
];
$capsule = new Illuminate\Database\Capsule\Manager;
$capsule->addConnection($dbConfig);
$capsule->setAsGlobal();
$capsule->bootEloquent();
$capsule->connection()->enableQueryLog(); // debug
self::$resolvedInstance['db'] = $capsule->connection();
}
return 'db';
}
}
class Schema extends Illuminate\Support\Facades\Facade
{
/**
* Get a schema builder instance for the default connection.
*
* @return \Illuminate\Database\Schema\Builder
*/
protected static function getFacadeAccessor()
{
return DB::getSchemaBuilder();
}
}