I have two comma separated arrays one for service ids and other for service quantities like this 1,2,3
for service ids and these are quantities 5,10,20
for service ids. Service id 1 have 5 quantity and id 2 have 10 and id 3 have 20 respectively. In this code i am getting services of ids but i have no idea how to set quantity against against those ids in loop and save. Hope you get my question.
I want to change $result['service_quantity'] when loop works first time 5 comes then 10 then 20. so that i can save that.
$checkRecord = Booking::where('id', $saveBooking->id)->get();
$allServicesArr = explode(",", $checkRecord[0]->services_ids);
$service = array();
for ($i = 0; $i < count($allServicesArr); $i++) {
$result = Service::find($allServicesArr[$i]);
if ($result['id'] != '') {
$service[$i]['id'] = $result['id'];
$service[$i]['category_id'] = $result['category_id'];
$service[$i]['event_id'] = $result['event_id'];
$service[$i]['service_name'] = $result['service_name'];
$service[$i]['service_kind'] = $result['service_kind'];
$service[$i]['service_price'] = $result['service_price'];
$service[$i]['service_quantity'] = $result['service_quantity'];
$service[$i]['service_detail'] = $result['service_detail'];
}
$insertDate = new BookedServices();
$insertDate->category_id = $result['category_id'];
$insertDate->event_id = $result['event_id'];
$insertDate->booking_id = $saveBooking->id;
$insertDate->user_id = $userID;
$insertDate->service_id = $result['id'];
$insertDate->bs_name = $result['service_name'];
$insertDate->bs_kind = $result['service_kind'];
$insertDate->bs_price = $result['service_price'];
$insertDate->bs_number = $result['service_number'];
$insertDate->bs_detail = $result['service_detail'];
$insertDate->save();
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire