title: Laravel updateOrCreate on OneToOne relationShip
body: <p>in my web application i have this models:</p>
  
  <pre><code>InstagramAccount.php 
  UserPageFeed.php
  </code></pre>
  
  <p>each InstagramAccount has one record into UserPageFeed and each UserPageFeed  belongs to one record into InstagramAccount, then that's <code>one to one</code> relationship, </p>
  
  <p><strong>PROBLEM:</strong></p>
  
  <blockquote>
    <p>my below code couldn't update existing row on table and create again</p>
  </blockquote>
  
  <pre><code>$userSelectedPage = InstagramAccount::whereUsername('my_page')-&gt;first();
  $userPageFeeds = new UserPageFeed();
  $userSelectedPage-&gt;account()-&gt;updateOrCreate([
      'instagram_account_id' =&gt; $userPageFeeds-&gt;id, //exsiting row
      'page_name' =&gt; 'test',
      'feeds' =&gt; 'test',
      'cache_time' =&gt; Carbon::now()-&gt;addHour(6),
  ]);
  </code></pre>
  
  <p>or this code:</p>
  
  <pre><code>$userSelectedPage = InstagramAccount::whereUsername('content.world')-&gt;first();
  $salam = $userSelectedPage-&gt;account()-&gt;updateOrCreate([
      'instagram_account_id' =&gt; $userSelectedPage-&gt;id,
      'page_name' =&gt; 'aaaaaaa',
      'feeds' =&gt; 'ddd',
      'cache_time' =&gt; Carbon::now()-&gt;addHour(6),
  ]);
  </code></pre>
  
  <p>user_page_feeds table structure:</p>
  
  <pre><code>id                     -&gt;Primary
  instagram_account_id   -&gt;Index
  feeds
  page_name
  cache_time
  created_at
  updated_at 
  </code></pre>
  
  <p>with this index:</p>
  
  <pre><code>"Keyname":user_page_feeds_instagram_account_id_foreign  "Column":instagram_account_id
  </code></pre>
  
  <p>instagram_accounts table structure:</p>
  
  <pre><code>id                     -&gt;Primary
  user_id                -&gt;Index
  uid
  fid
  proxy
  avatar
  username
  password
  checkpoint
  account_data
  people_data
  status
  created_at
  updated_at 
  </code></pre>
  
  <p><code>InstagramAccount</code> model:</p>
  
  <pre><code>class InstagramAccount extends Model
  {
      protected $guarded = ['id'];
  
      protected $casts = [
          'account_data' =&gt; 'array',
          'people_data' =&gt; 'array'
      ];
  
      public function user()
      {
          return $this-&gt;belongsTo(User::class);
      }
  
      public function account()
      {
          return $this-&gt;hasOne(UserPageFeed::class);
      }
  }
  </code></pre>
  
  <p><code>UserPageFeed</code> model:</p>
  
  <pre><code>class UserPageFeed extends Model
  {
      public $incrementing = false;
      protected $guarded = ['id'];
      protected $casts = [
          'feeds' =&gt; 'array'
      ];
  
      public function account()
      {
          return $this-&gt;belongsTo(InstagramAccount::class,'instagram_account_id');
      }
  }
  </code></pre>