backend/kernel/Database.php

45 lines
1.0 KiB
PHP
Raw Normal View History

2024-07-29 15:57:20 +03:00
<?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();
}
}