lundi 1 juillet 2019

updateOrCreate() is not working in laravel 5

I have a table named hierarchies as follows: enter image description here $reformedSubordinates is an array of user_id. Now I want to insert new entry or update if exist as follows:

  foreach($reformedSubordinates as $user_id) {

              Hierarchy::updateOrCreate(
                ['up' => $loggedInUserId, 'down' => $user_id],
                ['status' => 1]
            );
          }

But I am getting the following error:

SQLSTATE[HY000]: General error: 1364 Field 'status' doesn't have a default value (SQL: insert into `hierarchies` (`up`, `down`, `updated_at`, `created_at`) values (1, 2, 2019-07-02 05:18:02, 2019-07-02 05:18:02))

Whats wrong in my code? any idea?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Xqx3UI
via IFTTT

Aucun commentaire:

Enregistrer un commentaire