Я пытаюсь получить сумму столбца Price
с условием BillPaid
значение столбца должно быть 0
.
Мой кодовый блок
public function countDue()
{
$getTotalDue = DB::table('ordered_books')
->where('BillPaid', 0)
->sum('Price')
->get();
return response()->json($getTotalDue);
return compact('getTotalDue');
}
блок кода контроллера для вызова метода countDue
.
public function create()
{
return view('pages.booksin', $this->countDue());
}
просмотр страницы
<table id="showBooksIn" class="table table-bordered gridview">
<thead>
<tr><th>Total Due Amount</th></tr>
</thead>
<tbody>
@if(isset($getTotalDue))
@foreach($getTotalDue as $data)
<tr>
<td> {{$data}} </td>
</tr>
@endforeach
@endif
</tbody>
</table>
но я получаю сообщение об ошибке:
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to a member function get() on float
Моя структура таблицы: