Add inject to App::model

This commit is contained in:
William 2022-01-24 10:18:18 +01:00
parent 84434a4b00
commit 321ce8ae45

View File

@ -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