Skip to content

Commit

Permalink
Update Model.php
Browse files Browse the repository at this point in the history
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();
		}
```
  • Loading branch information
nowackipawel authored Jan 8, 2019
1 parent 2478a1f commit 747f28e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}
Expand Down

0 comments on commit 747f28e

Please sign in to comment.