title: Laravel Select Query within helper file
body: <p>I'm coming from codeigniter background. Unlike codeigniter helper directory, i just created helper directory within app directory of Laravel. Just want to know how to execute query within this common function. Here is my codeigniter function.</p>
  <pre><code>function show_menu($primary_key_col, $parent_id, $sort_order) 
  {
  $output = &quot;&quot;;
  $ci =&amp; get_instance();
  $ci-&gt;db-&gt;select(&quot;*&quot;);
  $ci-&gt;db-&gt;where('is_active', &quot;Y&quot;);
  $ci-&gt;db-&gt;where('is_delete', &quot;N&quot;);
  $ci-&gt;db-&gt;where('parent_id', $parent_id);
  ($sort_order!=&quot;&quot;)?$ci-&gt;db-&gt;order_by($sort_order, &quot;ASC&quot;):&quot;&quot;;
  $query = $ci-&gt;db-&gt;get('tbl_cms_menus');
  
  foreach ($query-&gt;result() as $row){
      $output .= '&lt;option value=&quot;'.$row-&gt;$primary_key_col.'&quot;&gt;'.$indent.$row-&gt;menu_name.'&lt;/option&gt;';
  }
  return $output; 
  }
  </code></pre>
  <p>I tried something like this in laravel file. but this code did't give me any result. Please tell me where i'm doing wrong in this code. thanks</p>
  <pre><code>function databaseTable()
  {
     $table = DB::table('tbl_cms_menus');
     $get_rows = $table-&gt;get();
     $count_rows = $table-&gt;count();
  
     if($count_rows &gt; 0){
      foreach ($get_rows as $tbl)
      {
          echo $tbl-&gt;menu_name;
      }
    }
  }
  </code></pre>