App]
This commit is contained in:
45
kernel/Database.php
Executable file
45
kernel/Database.php
Executable file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: kirill
|
||||
* Date: 03.08.19
|
||||
* Time: 23:51
|
||||
*/
|
||||
|
||||
namespace kernel;
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use Illuminate\Container\Container;
|
||||
use Phroute\Phroute\Dispatcher;
|
||||
|
||||
class Database
|
||||
{
|
||||
/** @var Builder $capsule */
|
||||
public Builder $schema;
|
||||
|
||||
/** @var Capsule $capsule */
|
||||
public Capsule $capsule;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->capsule = new Capsule;
|
||||
$this->capsule->addConnection([
|
||||
'driver' => $_ENV['DB_DRIVER'],
|
||||
'host' => $_ENV['DB_HOST'],
|
||||
'database' => $_ENV['DB_NAME'],
|
||||
'username' => $_ENV['DB_USER'],
|
||||
'password' => $_ENV['DB_PASSWORD'],
|
||||
'charset' => $_ENV['DB_CHARSET'],
|
||||
'collation' => $_ENV['DB_COLLATION'],
|
||||
'prefix' => $_ENV['DB_PREFIX'],
|
||||
]);
|
||||
// Setup the Eloquent ORM…
|
||||
|
||||
$this->capsule->setAsGlobal();
|
||||
|
||||
$this->capsule->bootEloquent();
|
||||
|
||||
$this->schema = $this->capsule->schema();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user