Autowire database connection.

This commit is contained in:
Krzysztof Płaczek
2025-05-14 13:14:57 +02:00
parent dc287aadc6
commit f30304cbe9
5 changed files with 27 additions and 14 deletions

View File

@@ -11,11 +11,7 @@ class BaseController extends AbstractController
{
protected Environment $twig;
public function __construct(protected FilesystemAdapter $cache)
public function __construct(protected FilesystemAdapter $cache, protected Capsule $database)
{
$capsule = new Capsule;
$capsule->addConnection(['driver' => 'sqlite', 'database' => __DIR__ . '/../../database.sqlite']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
}
}