gpt4 book ai didi

php - 如何使用 Laravel 5.4 中的 Controller 从我的数据库传递 5 个不同数据的总和数据?

转载 作者:可可西里 更新时间:2023-11-01 00:55:37 25 4
gpt4 key购买 nike

我是 laravel 5.4 的新手,当我在数据库中查看具有 id 的特定 guest 时,我想从我的数据库中获取 5 个不同数据的总和?我无法得到总和或总数

这是我的代码:

public function show($id)
{
$forPayment = ForPayment::where('application_number', $id)->get()->last();

if (empty($forPayment)) {
Flash::error('For Payment not found');

return redirect(route('forPayments.index'));
}
$inspection_fee = $forPayment->inspection_fee;
$storage_fee = $forPayment->storage_fee;
$cert_fee = $forPayment->cert_fee;
$local_fee = $forPayment->local_fee;
$others_fee = $forPayment->others_fee;

$total_fee = $inspection_fee + $storage_fee + $cert_fee + $local_fee + $others_fee;

return view('cashier-dashboard.paid.show')->with('forPayment', $forPayment, $total_fee);
}

最佳答案

return view('cashier-dashboard.paid.show',compact('forPayment','total_fee'));

试试这个

关于php - 如何使用 Laravel 5.4 中的 Controller 从我的数据库传递 5 个不同数据的总和数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45410793/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com