-
Notifications
You must be signed in to change notification settings - Fork 478
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
Observers not working #221
Comments
OK, it seems like before_get is the wrong observer to use in my case. I want to get the data, then append it. It seems whatever I do in before_get is getting overwritten. So what use is before_get if data is going to be overwritten? Looks like after_get works for me, for now. |
I'm finding that the $this->user_model->insert(array(
'forename' => 'Jim',
'surname' => 'Testing',
'username' => 'j.testing1234',
'password' => 'awesomepassword'
)); Then in my user_model.php class User_model extends MY_Model{
protected $before_create = array('hash_password');
protected $before_update = array('hash_password');
protected $soft_delete = true;
public function __construct(){
parent::__construct();
$this->soft_delete = true;
}
/**
* Hash Password
*
* Creates a cryptographically secure password hash for users
*
* @param array $user The database row representing the user
* @return array The database row representing the user
*/
protected function hash_password($user){
if(array_key_exists('password', $user)){
$user['password'] = password_hash($user['password'], PASSWORD_BCRYPT);
}
return $user;
}
} |
I am trying to get a simple observer working, but to no avail.
I am using the following code (as shown in the documentation)
Checking the variables using a break point, shows that the object returned does not contain the created_at or updated_at data.
Do I need to enable the triggers somehow?
I am using CI3 btw.
The text was updated successfully, but these errors were encountered: