В моем приложении я хочу передать идентификатор по одному виду формы в контроллер с помощью jquery и суммировать там значение
и печать в поле зрения
как я могу это помочь любому телу
ожидаемый результат 25, а не 13 в общей стоимости
это вид
http://prntscr.com/nam2nb
это мой контроллер
public function price_count(Request $request)
{
$total_parice = DB::table('tms_store')
->where('product_id', $request->id)
->select(DB::raw('sum(product_price) as total_amount'))
->first();
Session::put('price', $total_parice);
$price = Session::get('price');
return response()->json($price);
}
это jquery
function total_amount(id)
{
var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
$.ajax({
url: APP_URL+"/driver-equipment/price",
type: 'POST',
dataType: 'json',
data: {_token: CSRF_TOKEN,'id' : id},
})
.done(function(res) {
console.log(res)
$("#totalPrice").val(res.total_amount);
})
.fail(function() {
console.log("error");
})
}