00 Day
00 Hour
00 Min
00 Sec

Syntax for updating data

Home Forums General Syntax for updating data

Viewing 4 reply threads
  • Author
    Posts
    • #69991
      Gordian
      Participant

      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?

    • #70000
      Gordian
      Participant

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

    • #70071
      Jay
      Participant

      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

    • #70102
      Gordian
      Participant

      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.

    • #70104
      Gordian
      Participant

      @mehedi,
      thanks for your help! I did it. I deleted ‘einformed’ variable from Class Employee protected data.

Viewing 4 reply threads
  • The forum ‘General’ is closed to new topics and replies.

Contact Us

Reach out to us for any inquiry

You must enter full name
You must enter email
You must enter message

We received your query

We will reply to you very soon :)