Reputation:
I'm trying to achieve subtracting two integer values different tables, this is what I have tried so far.
Controller:
$amount = DB::table('shipping_datas')->where('amount')->first();
$payment = DB::table('payments')->where('amount')->first();
$balance = $amount - $payment;
Blade:
{{ $balance }}
Thank you in advance :)
Upvotes: 5
Views: 2582
Reputation: 198
$amount = DB::table('shipping_datas')->pluck('amount')->sum();
$payment = DB::table('payments')->pluck('amount')->sum();
$balance = $amount - $payment;
i think its work.
Upvotes: 3