public function __construct($modelName) { $modelId = ElegantModel::generateId($modelName); if (!($model = Config::getModelById($modelId))) { throw new \Exception('Model not found with name ' . $modelName); } $this->elegantModel = $model; parent::__construct($this->elegantModel->getModelInstance()); }