title: Laravel Method Illuminate\Database\Eloquent\Collection::toSql does not exist. error
body: <p>I want to search all records from database and then filter these records but when i want to seee the query with </p>
  
  <pre class="lang-php prettyprint-override"><code>dd($posts-&gt;toSql());
  </code></pre>
  
  <p>it gives me the error</p>
  
  <pre class="lang-php prettyprint-override"><code>"Illuminate\Database\Eloquent\Collection::toSql does not exist."
  </code></pre>
  
  <p>it gives me one more error</p>
  
  <pre class="lang-php prettyprint-override"><code>"Method Illuminate\Database\Eloquent\Collection::paginate does not exist."
  </code></pre>
  
  <pre class="lang-php prettyprint-override"><code>$posts = Post::all();
  
          if( !is_null($brand) )
              $posts = $posts-&gt;where('brand', $brand);
  
          if( !is_null($car_type) )
              $posts = $posts-&gt;where('car_type', $car_type);
  
          if( !is_null($color) ){
              $posts = $posts-&gt;where('exterior_color', $color);
          }
          $posts = $posts-&gt;whereBetween('year',[$from_year,$to_year]);   
          $posts = $posts-&gt;whereBetween('milage',[$min_milage,$max_milage]);
          $posts = $posts-&gt;whereBetween('price',[$min_price,$max_price]);
  
          $posts = $posts-&gt;paginate(4);
  
          dd($posts-&gt;toSql());
  
  </code></pre>