I collected data from a database and the data is based upon user id, ie I select data from database table based 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?
Using Laravel 5.4, I query my db as follows:
$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 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 values to themselves, so please can anyone tell me how this is done?