- This topic has 4 replies, 2 voices, and was last updated 4 years, 7 months ago by Gordian.
-
AuthorPosts
-
-
March 30, 2020 at 5:02 pm #69991GordianParticipant
Good day guys!
Could you help me please. I would like to update a field in the employee table in case date_of_birth was changed. I’d found employee update function, but I can’t use syntax in right way.
There is a code:
$this->erp-user->update ( [ ‘lalala’ => ‘dadada’ ] ) ;My field in DB is situated also in employee table. But this code does not work. Any chance you can give an estimate how to use it?
-
March 30, 2020 at 5:56 pm #70000GordianParticipant
This is my code inside class-employee.php, update employee function of hrm module.
//update user einformed if license_date was changed
if ( isset( $posted[‘license_date’] ) && $posted[‘license_date’] !== $this->erp_user->license_date ) {$this->erp_user->update( [ ‘user_id’ => $this->user_id, ‘einformed’ => ‘no’ ] );
if ( is_wp_error( $result ) ) {
return $result;
}
} -
March 31, 2020 at 11:20 am #70071JayParticipant
Hello Gordian,
It’s really tough to say specifically without knowing the complete scenario you have but make sure you are adding your code on the fillable to update the Eloquent model. Something like:
wp-content/plugins/wp-erp/modules/hrm/includes/models/employee.php:21 protected $fillable = [ 'user_id', 'employee_id', 'designation', 'department', 'location', 'hiring_source', 'hiring_date', 'termination_date', 'date_of_birth', 'reporting_to', 'pay_rate', 'pay_type', 'type', 'status', 'delete_at' ];
You can also post it to our GitHub so that other developers can have a look on it.
Thanks
-
March 31, 2020 at 4:35 pm #70102GordianParticipant
Thank you!
Just to make it clear… I created a field in employees table. The name of field is ‘einformed’.
I want this field to take parametr ‘no’ in case if posted date of birth (in the form) is not the same as it is in DB. So, ‘einformed ‘ variable doesn’t mentioned is the form. I’m trying to use it only in ‘update employee’ function.P.S. I’v added it to the employee model, but there is no success.
-
March 31, 2020 at 5:22 pm #70104
-
-
AuthorPosts
- The forum ‘General’ is closed to new topics and replies.