From 321ce8ae45292a22248decbef1537bc40abadcfb Mon Sep 17 00:00:00 2001 From: William Date: Mon, 24 Jan 2022 10:18:18 +0100 Subject: [PATCH] Add inject to App::model --- app/core/App.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/core/App.php b/app/core/App.php index f130c68..f273a46 100644 --- a/app/core/App.php +++ b/app/core/App.php @@ -21,12 +21,15 @@ class App } // Grab model - public function model(string $model): object + public function model(string $model, $injection = NULL): object { // Require model file require __DIR__ . '/../model/' . $model . '.php'; // Instantiate model - return new $model(); + if (!$injection) { + $injection = $this->database; + } + return new $model($injection); } // Render given view