I collected a data from a database and the data is base on o user id id, ie I select data from database table base on a user id. Now the selected result has some value (numbers) how do i check if that total sum of the number is equal to a certain amount. Am using Laravel 5.4 I query my db as follow
$money = $DBTable::where('id', Auth::user()->id)->get();
now i have a column called cash
how do i get the total sum of the cash column. what is the code for that since the result is an object do i do a foreach loop
foreach ($money as $key => $value) {
count($money->cash);
}
this will return the number count of the value
foreach ($money as $key => $value) {
echo $earn->earned_amount + $earn->earned_amount;
}
this will add up individual value to themselves. so please can anyone tell me how it is done.
via dagogodboss