title: Error when I save model in Laravel. 'Call to a member function getKey() on a non-object'
body: <p>I try save my object in DB by this code:</p>
  
  <pre><code>$preview = new ProjectProductPreview();
  $preview-&gt;user_id = $user_id;
  $preview-&gt;path = $preview_url;
  $preview-&gt;type = $type;
  $preview-&gt;project_product_id = $product_id;
  $preview-&gt;save();  
  </code></pre>
  
  <p>And I got strange error. This error occurs when call save() method.
  I have checked my laravel logs, there is this error. I can debug this precisely because in this case, error stack has only two positions</p>
  
  <pre><code>[2015-02-17 09:37:30] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to a member function getKey() on a non-object' in /var/www/erp/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php:133
      Stack trace:
      #0 [internal function]: Illuminate\Exception\Handler-&gt;handleShutdown()
      #1 {main} [] []
  </code></pre>
  
  <p>My model looks like:</p>
  
  <p>
  
  <pre><code>class ProjectProductPreview extends BaseModel {
  
      protected $table = 'project_products_preview';
  
  
      public function user() {
          return $this-&gt;belongsTo('User');
      }
  
      public function project_product() {
          return $this-&gt;belongsTo('ProjectProduct', 'project_product_id');
      }
  
      public function projectProduct()
      {
          return $this-&gt;belongsTo('ProjectProduct', 'project_product_id');
      }
  
      public function message() {
          return $this-&gt;belongsToMany('Message');
      }
  
      public function getThumb() {
          $path = $this-&gt;path;
          $thumb_path = str_replace('.jpg', '_70.jpg', $path);
          return $thumb_path;
      }
  
      public function fullPath() {
          return public_path($this-&gt;path);
      }
  
      public function getPath()
      {
          return $this-&gt;path;
      }
  
      public function getUrlAttribute() {
          $product_id = $this-&gt;project_product_id;
  
          return '/product/' . $product_id . '#' . $this-&gt;id;
      }
  
      public function isAccepted()
      {
          if($this-&gt;accepted==1){
              return true;
          }
  
          return false;
      }
  
      public function accept()
      {
          ProjectProductPreview::where('project_product_id',$this-&gt;project_product_id)-&gt;update(array('accepted'=&gt;0));
          $this-&gt;accepted=1;
          $this-&gt;save();
  
          Event::fire('project_product_preview.accepted', array($this));
      }
  
      public function acceptRemove()
      {
          $this-&gt;accepted=0;
          $this-&gt;save();
  
          Event::fire('project_product_preview.remove_accept', array($this));
      }
  
  }
  </code></pre>