vendredi 19 janvier 2018

How prevent update some fields in updateOrCreate?

I try to check if Instagram profile exists in my database if not exists I create it, if exists I update all fields.

 InstagramProfile::updateOrCreate([
       'instagram_id' => $instagramUser->data->id,
    ], [
       'profile_id' => $author_id = Profile::firstOrCreate([
          'username' => $instagramUser->data->username,
       ])->id,
       ...
    ]);

Problem: when it new InstagramProfile - all works ok, but when I update exists I create new Profile. Question: how prevent update some fields in updateOrCreate()?



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

Aucun commentaire:

Enregistrer un commentaire