title: How to update a pivot table using Eloquent in laravel 5
body: <p>I am new to laravel. I am working on a laravel 5 app and I am stuck here. I have 2 models as such:</p>
  
  <pre><code>class Message extends Eloquent{
  
      public function user()
      {
          return $this-&gt;belongsTo('App\User', 'from');
      }
  
      public function users()
      {
          return $this-&gt;belongsToMany('App\User')-&gt;withPivot('status');
      }
  }
  
  class User extends Eloquent {
  
      public function messages()
      {
          return $this-&gt;hasMany('App\Message', 'from');
      }
  
      public function receive_messages() {
          return $this-&gt;belongsToMany('App\Message')-&gt;withPivot('status');
      }
  }
  </code></pre>
  
  <p>There exist a many-to-many relationship between Message and User giving me a pivot table as such:</p>
  
  <pre><code>Table Name: message_user
  Colums:
  message_id
  user_id
  status
  </code></pre>
  
  <p>I have an SQL query as such:</p>
  
  <pre><code>update message_user
  set status = 1
  where user_id = 4 and message_id in (select id from messages where message_id = 123)
  </code></pre>
  
  <p>How can I translate this query to the laravel equivalent?</p>