Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBGroup in __get(), allows to validate "database" data outside the model. #1656

Merged
merged 1 commit into from
Jan 10, 2019

Conversation

nowackipawel
Copy link
Contributor

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();
		}

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();
		}
```
@lonnieezell lonnieezell merged commit 6450c6f into codeigniter4:develop Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants