|
@@ -3,16 +3,21 @@
|
|
namespace Src;
|
|
namespace Src;
|
|
|
|
|
|
use Error;
|
|
use Error;
|
|
|
|
+use Illuminate\Container\Container;
|
|
|
|
+use Illuminate\Events\Dispatcher;
|
|
|
|
+use Illuminate\Database\Capsule\Manager as Capsule;
|
|
|
|
|
|
class Application
|
|
class Application
|
|
{
|
|
{
|
|
private Settings $settings;
|
|
private Settings $settings;
|
|
private Route $route;
|
|
private Route $route;
|
|
|
|
+ private Capsule $dbManager;
|
|
|
|
|
|
public function __construct(Settings $settings)
|
|
public function __construct(Settings $settings)
|
|
{
|
|
{
|
|
$this->settings = $settings;
|
|
$this->settings = $settings;
|
|
$this->route = new Route();
|
|
$this->route = new Route();
|
|
|
|
+ $this->dbManager = new Capsule();
|
|
}
|
|
}
|
|
|
|
|
|
public function __get($key)
|
|
public function __get($key)
|
|
@@ -23,9 +28,18 @@ class Application
|
|
throw new Error('Accessing a non-existent property');
|
|
throw new Error('Accessing a non-existent property');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private function dbRun()
|
|
|
|
+ {
|
|
|
|
+ $this->dbManager->addConnection($this->settings->getDbSettings());
|
|
|
|
+ $this->dbManager->setEventDispatcher(new Dispatcher(new Container));
|
|
|
|
+ $this->dbManager->setAsGlobal();
|
|
|
|
+ $this->dbManager->bootEloquent();
|
|
|
|
+ }
|
|
|
|
+
|
|
public function run(): void
|
|
public function run(): void
|
|
{
|
|
{
|
|
|
|
+ $this->dbRun();
|
|
$this->route->setPrefix($this->settings->getRootPath());
|
|
$this->route->setPrefix($this->settings->getRootPath());
|
|
$this->route->start();
|
|
$this->route->start();
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|