title: Laravel where query not working
body: <p>I've got this table</p>
  
  <h2>beds</h2>
  
  <p>id</p>
  
  <p>name</p>
  
  <p>size</p>
  
  <p>room</p>
  
  <p>status</p>
  
  <p>hotel</p>
  
  <p>created_at</p>
  
  <p>updated_at</p>
  
  <p>I need to filter all beds that belong to a certain room. In order to do so, I've coded this lines.</p>
  
  <pre><code>public function index()
      {
          //
          $user = JWTAuth::parseToken()-&gt;authenticate();
          $data = Input::get('room');
          if( $data ){
              $beds = Bed::where('room', '=', $data )-&gt;get();
          }else{
              $beds = Bed::where('hotel', '=', $user-&gt;hostel )-&gt;get();    
          }
  
          foreach( $beds as $bed) {
              return $bed-&gt;get( array('size','room', 'id') );
          }
      }
  </code></pre>
  
  <p>So, If i give it the room id, it should return me only that room's ones.
  The thing is that it's returning all table entries.</p>
  
  <p>Any ideas?</p>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>Fixed relations and tried this:</p>
  
  <pre><code>return Room::with('beds')-&gt;findOrFail($data)-&gt;beds;
  </code></pre>
  
  <p>Now it gives me the number of items.
  How can I get the items?</p>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>This is the model's code:</p>
  
  <pre><code>class Room extends \Eloquent {
      protected $fillable = array('beds', 'price', 'name', 'description','hotel');
  
      public function beds(){
          return $this-&gt;hasMany('Bed', 'id', 'room');
      }
  }
  </code></pre>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>The var_dump for:</p>
  
  <pre><code>var_dump( Room::with('beds')-&gt;findOrFail($data)-&gt;beds );
  </code></pre>
  
  <p>is:</p>
  
  <pre><code>int(1)
  </code></pre>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>So, the final code is the following.</p>
  
  <p>controller</p>
  
  <pre><code>public function index()
      {
          //
          $user = JWTAuth::parseToken()-&gt;authenticate();
          $data = Input::get('room');
          if( $data ){
              $d = intval( $data );
              return Bed::where('room', '=', $d )-&gt;get( array('size', 'room', 'id', 'name') );
          }else{
              return Bed::where('hotel', '=', $user-&gt;hostel )-&gt;get( array('size', 'room', 'id', 'name') );    
          }
  
      }
  </code></pre>
  
  <p>model</p>
  
  <pre><code>class Room extends \Eloquent {
      protected $fillable = array('beds', 'price', 'name', 'description','hotel');
  
      public function camas(){
          return $this-&gt;hasMany('Bed', 'room', 'id');
      }
  }
  </code></pre>
  
  <p>Thank you guys!</p>