title: Laravel how to get a Model by two parameters
body: <p>Hi I'm new to Laravel and got stuck in a Problem.</p>
  
  <p>I have a model <code>Contact</code> </p>
  
  <pre><code>class Contact extends Eloquent {
      /**
       * The database table used by the model.
       *
       * @var string
       */
      protected $table = 'contacts';
  }
  </code></pre>
  
  <p>The table have these fields:</p>
  
  <pre><code>user_id (int)
  contact_id (int)
  ...
  </code></pre>
  
  <p>these two fields represent the primary key.</p>
  
  <p>In the <code>ContactsController</code> I have the function <code>store</code> in wich I create or update the database:</p>
  
  <pre><code>public function store()
  {
  
      switch (Input::get('type')){
          case 'make_contact_request':
  
              $user = User::where('email', '=', Input::get('login'));
  
              $request_self = new Contact;
              $request_contact = new Contact;
  
              $request_self-&gt;user_id = Auth::user()-&gt;id;
              $request_self-&gt;contact_id = $user-&gt;id;
              $request_self-&gt;status = 2;
              $request_self-&gt;message = Input::get('message');
  
              $request_contact-&gt;user_id = $user-&gt;id;
              $request_contact-&gt;contact_id = Auth::user()-&gt;id;
              $request_contact-&gt;status = 1;
              $request_contact-&gt;message = Input::get('message');
  
              $request_self-&gt;save();
              $request_contact-&gt;save();
              break;
          case 'answer_contact_request':
  
              $request_self = Contact::where('user_id', '=',Input::get('contact_id'))-&gt;where('contact_id', '=', Auth::user()-&gt;id)-&gt;first();
              //$request_self = Contact::whereRaw('user_id = '.Input::get('contact_id').' AND contact_id = '.Auth::user()-&gt;id.' ');
              $request_contact = Contact::whereRaw('user_id = '.Auth::user()-&gt;id.' AND contact_id = '.Input::get('contact_id').' ');
  
              $request_self-&gt;status = 3;
              $request_contact-&gt;status = 3;
  
              $request_self-&gt;save();
              $request_contact-&gt;save();
              break;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I tried two different ways to get the <code>Contact</code> Object for the <code>request_self</code> Object and I get the following error:</p>
  
  <pre><code>message: "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: update `contacts` set `status` = 3, `updated_at` = 2014-08-02 16:16:56 where `id` is null)"
  </code></pre>
  
  <p>for the <code>request_contact</code> Object it throws a fatal error (don't get the description) and close the session.</p>
  
  <p>At the end I am at the beginning of laravel so I hope the solution is pretty easy to find :) but I dont even really know for what to search. </p>
  
  <p><strong>Update:</strong></p>
  
  <p>At the end I fixed the Problem with the <code>update</code> function.</p>
  
  <pre><code> case 'answer_contact_request':
  
              $request_self = Contact::where('user_id', '=',Input::get('contact_id'))-&gt;where('contact_id', '=', Auth::user()-&gt;id)-&gt;update(array('status' =&gt; 3));
              $request_contact = Contact::where('user_id', '=', Auth::user()-&gt;id)-&gt;where('contact_id', '=', Input::get('contact_id'))-&gt;update(array('status' =&gt; 3));
  
              break;
  </code></pre>