I have been trying to get price data from table 'rates' and store it in another table 'bookings'.
$duit =Booking::Join('rates', 'bookings.park_area','=', 'rates.areaid')
->where('bookings.user_id', '=', Auth::user()->userid)
->where('bookings.park_area','=',$bookings->park_area)
->where('bookings.semester','=',$bookings->semester)
->first(['rates.price']);
$bookings->price=($duit);
$bookings->save();
However, i get an error stating that the value retrieve is not of a double datatype: {"price":80}. So, I tried changing first(['rates.price']);
to value('rates.price')
but it stores as null.
So, why does {"price":80} become null and how to get the value of 80?
you can used like that use select
method here or directly get
get object value directly ->first()->price
instead or this -->first(['rates.price']);
$duit = Booking::Join('rates', 'bookings.park_area','=', 'rates.areaid')
->where('bookings.user_id', '=', Auth::user()->userid)
->where('bookings.park_area','=',$bookings->park_area)
->where('bookings.semester','=',$bookings->semester)
->select('rates.price')
->first()->price;
$bookings->price = $duit;
$bookings->save();