title: Secure laravel query which use DB::Raw
body: <p>I'm really new in Laravel and I'm not sure how can I secure from <code>SQL Injections</code> query which use <code>DB::Raw</code>. I have read trough <a href="https://laravel.com/docs/4.2/queries#raw-expressions" rel="nofollow">documentation</a> and I've read that is kind of insecure and should be secured since it's injected in the query as a string...</p>
  
  <blockquote>
    <p>These expressions will be injected into the query as strings, so be careful not to create any SQL injection points</p>
  </blockquote>
  
  <p>Myquery looks like this</p>
  
  <pre><code>DB::table('sub_category as sc')
      -&gt;leftJoin('products as p', 'p.sub_cat_id', '=', 'sc.sub_cat_id')
      -&gt;where('sc.category_id', '=', $categoryId)
      -&gt;whereNotNull('p.sub_cat_id')
      -&gt;select('p.*','sc.*', DB::raw('sc.sub_cat_id AS sub_cat_id'))
      -&gt;groupBy('sc.sub_cat_id')
      -&gt;get();
  </code></pre>
  
  <p>The query simply display on page only categories which have products in it.</p>