title: Laravel Query Builder avg() method, float number problem
body: <p>Trying to create a 5-star rating system in Laravel.
  a star rate is a float number in the range [1 to 5] and it stores successfully in the database.
  migration file for rates table in database. ( I've set data type of star column as float)</p>
  
  <pre><code>public function up()
  {
      Schema::create('rates', function (Blueprint $table) {
          $table-&gt;id();
          $table-&gt;morphs('rateble');     //creates rateable_id  and  rateable_type
          $table-&gt;foreignId('user_id')-&gt;nullable()-&gt;constrained()-&gt;onUpdate('cascade')-&gt;onDelete('set null');
          $table-&gt;float('star',2, 1);    //star number is from 0 to 5 
          $table-&gt;timestamps();
      });
  }
  </code></pre>
  
  <p>Then for averaging the rating for a specific product, I am using this query:</p>
  
  <pre><code>public function scopeAverageRate($query, $type, $id)
  {
      return $query-&gt;where('rateble_type', $type)
                   -&gt;where('rateble_id', $id)
                   -&gt;avg('star');
  }
  </code></pre>
  
  <p>The problem is, it seems that the <code>avg()</code> method cast the result to integer! Is there any way to set this function to work with the float numbers?</p>
  
  <p>e.g. assume there is only one rate for a specific product that equals "0.5" stars then the average rating is "0" instead of  "0.5" !</p>
  
  <p>How can I solve this problem?</p>
  
  <p>Thank you in advance,</p>