title: Getting value from query builder select count result in Laravel
body: <p>I have a query builder in Laravel controller to get total value of total select table row from database, and I want to get the result value, but the result always give me an array result, and I've tried to access the value from the array but I still cant get the value</p>
  
  <p>Here's the query builder: </p>
  
  <pre><code>$total = DB::select(DB::raw("SELECT COUNT(*) FROM hstmemb WHERE period = '".$bonperiod."' AND totbns &lt;&gt; 0 AND paytype = 'S'"));
  $getbonus[0]-&gt;total = $total;
  </code></pre>
  
  <p>The result I get is an array object, but I want to get just the count result in int number.</p>