title: Laravel Error Calling Member Function
body: <p>I followed some tutorial on <a href="http://laravel.com/docs/" rel="nofollow">http://laravel.com/docs/</a> and it just won't work. Here's what I tried:</p>
  
  <p>Role model:</p>
  
  <pre><code>&lt;?php
  
  class Role extends Eloquent {
  
      protected $table = 'accounts';
  
      public function users()
      {
          return $this-&gt;belongsToMany('User');
      }
  }
  </code></pre>
  
  <p>RoleController.php</p>
  
  <pre><code>&lt;?php
  
  class RoleController extends BaseController {
  
      public function get_role()
      {
          $roles = User::find(16)-&gt;group_id;
  
          if ($roles-&gt;contains(3))
          {
              echo 'this works';
          }
          else
          {
              return Redirect::to('news/index');
          }
      }
  }
  </code></pre>
  
  <p>And my route:</p>
  
  <pre><code>Route::get('dash', 'RoleController@get_role');
  </code></pre>
  
  <p>And here's my error:</p>
  
  <pre><code>Call to a member function contains() on a non-object
  </code></pre>
  
  <p>It says the error is on line:</p>
  
  <pre><code>if ($roles-&gt;contains(3))
  </code></pre>
  
  <p>Like the contains method is... I don't know hah.</p>
  
  <p>Also, <code>$roles = User::find(16)-&gt;group_id;</code>
  The 16 is the <code>id</code> of the account, right? And the <code>group_id</code> is the table?</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT:</p>
  
  <p>Here's the solution, I've changed it in <code>RoleController.php</code>:</p>
  
  <pre><code>&lt;?php
  
  class RoleController extends BaseController {
  
      public function get_role()
      {
          $roles = User::find(16)-&gt;group_id;
  
          if (if ($roles == '1')
          {
              echo 'this works';
          }
          else
          {
              return Redirect::to('news/index');
          }
      }
  }
  </code></pre>