From 747f28ef5abf95d709cefdf7dbb6e5b8352de422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Nowacki?= Date: Tue, 8 Jan 2019 15:53:46 +0100 Subject: [PATCH] Update Model.php We need it outside model if we'd like to run validation rules which are connecting to database OUTSIDE our model. ``` if($this->request->getPost('p')) { $post = $this->request->getPost('p'); $user_model = (new \UserModel()); $validation = \Config\Services::validation(); $validation->setRules($user_model->getValidationRules())->run($data, null, $user_model->DBGroup); d($validation->getErrors(),$this->request->getPost());die(); } ``` --- system/Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Model.php b/system/Model.php index 8f62ab84d367..68c176f99751 100644 --- a/system/Model.php +++ b/system/Model.php @@ -1436,7 +1436,7 @@ protected function trigger(string $event, array $data) */ public function __get(string $name) { - if (in_array($name, ['primaryKey', 'table', 'returnType'])) + if (in_array($name, ['primaryKey', 'table', 'returnType', 'DBGroup'])) { return $this->{$name}; }