title: number_format() expects parameter 1 to be double, array given
body: <p>I'm new to laravel so sorry if this question seems simple and such.</p>
  
  <p>I want to show the sum of the credit_memo in a given month and year but it shows the error: "number_format() expects parameter 1 to be double, array given " and I don't know what is the source of the error.</p>
  
  <p>CreditMemoModel</p>
  
  <pre><code>&lt;?php namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class CreditMemoModel extends Model{
      public $table = "credit_memo";
  
      public function getTotalAmount(){
          return $this-&gt;credit_memo()-&gt;total_amount;
      }
  }
  
  ?&gt;
  </code></pre>
  
  <p>CMController (just the CreditMemo related ones)</p>
  
  <pre><code>use App\CreditMemoModel;
  $credit_memos = CreditMemoModel::all();
  $data               = [];
      foreach($date_arr as $date_index){
        foreach ($credit_memos as $credit_memo) {
              $data[$date_index]['credit_memos'][$credit_memo-&gt;total_amount] = 0;
          }
  }
  </code></pre>
  
  <p>and the view</p>
  
  <pre><code>&lt;td&gt;Credit Memo&lt;/td&gt;
          @foreach($date_arr as $date)
          &lt;td class="text-right"&gt;{{ number_format($data[$date]['credit_memos'],2) }}&lt;/td&gt;
          &lt;?php $qtotal += $data[$date]['credit_memos']; ?&gt;
        @endforeach
        &lt;td class="text-right"&gt;{{number_format($qtotal, 2)}}&lt;/td&gt;
  </code></pre>