'Error : Object of class Illuminate\Support\Collection could not be converted to int [duplicate]
$total1 = DB::table('listrik_depan')->select('depan_pakaiwbp1200')->get();
$total2 = DB::table('listrik_belakang')->select('belakang_pakaiwbp60')->get();
$seluruh = $total1 + $total2;
dd($seluruh);
Error : Object of class Illuminate\Support\Collection could not be converted to int
Please help me, what should I do?
Solution 1:[1]
get() return object of table not single value.
use like this way DB::table('listrik_depan')->value('depan_pakaiwbp1200') instead of get()
$total1 = DB::table('listrik_depan')->value('depan_pakaiwbp1200');
$total2 = DB::table('listrik_belakang')->value('belakang_pakaiwbp60');
$seluruh = $total1 + $total2;
dd($seluruh);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bhargav Chudasama |
