php-如何使用Laravel 5.4中的控制器从数据库传递5个不同数据之和的数据?
作者:互联网
我是laravel 5.4的新手,当我查看数据库中具有ID的特定来宾时,我想从数据库中总计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'));
尝试这个
标签:laravel-5-4,laravel,php 来源: https://codeday.me/bug/20191025/1931480.html