title: Laravel 4 passing database query from model to controller - error call to member function on non-object
body: <p>Confused about why this isn't working, trying to pass a database query function to my controller. I am receiving the error <code>Call to a member function getCompanyData() on a non-object</code></p>
  
  <p><strong>Review.php</strong> (Model)</p>
  
  <pre><code>class Review extends Eloquent {
  
      public function getCompanyData($company)
      {
          return $this-&gt;select('head', 'body', 'logo', 'name')
              -&gt;where('company', '=', $company)
              -&gt;firstOrFail();
      }
  }
  </code></pre>
  
  <p><strong>ReviewController.php</strong></p>
  
  <pre><code>class ReviewController extends BaseController {
  
      protected $review;
  
      public function __construct(Review $review)
      {
          $this-&gt;beforeFilter('csrf', array('on' =&gt; 'post'));
          $this-&gt;review = $review;
      }
  
      public function show($company)
      {
          $data = $this-&gt;review-&gt;getCompanyData($company);
  
          return View::make('reviews.show', compact('data'));
      } 
  }
  </code></pre>