public function save() { if (Request::ajax()) { $data = Request::all(); $date_con = json_decode($data['data'], true); $data_save = ['id' => $date_con['id'], 'roomtype_id' => $date_con['roomtype_id'], 'solution' => $date_con['solution'], 'apdunglamtron' => $date_con['apdunglamtron'], 'moc1' => $date_con['moc1'], 'moc2' => $date_con['moc2'], 'lamtron1' => $date_con['lamtron1'], 'lamtron2' => $date_con['lamtron2'], 'lamtron3' => $date_con['lamtron3'], 'tinhtheothoigian' => $date_con['tinhtheothoigian'], 'tinhtheongaydem' => $date_con['tinhtheongaydem'], 'khunggiobatdau' => $date_con['khunggiobatdau'], 'khunggioketthuc' => $date_con['khunggioketthuc'], 'A001to' => $date_con['A001to'], 'A001price' => $date_con['A001price'], 'nuangayfrom' => $date_con['nuangayfrom'], 'nuangayto' => $date_con['nuangayto'], 'nguyenngayfrom' => $date_con['nguyenngayfrom'], 'nguyenngayto' => $date_con['nguyenngayto'], 'gianuangay' => $date_con['gianuangay'], 'gianguyenngay' => $date_con['gianguyenngay'], 'giatheogio' => $date_con['giatheogio'], 'giaquadem' => $date_con['giaquadem'], 'tinhphutroi' => $date_con['tinhphutroi'], 'nguoiphutroi' => $date_con['nguoiphutroi']]; $data_time_237 = $date_con['khunggio7AM_23PM']; $data_phutroi = $date_con['phutroi']; foreach ($data_time_237 as $key => $record) { $del = isset($record['delete']) ? $record['delete'] : 0; $id = isset($record['id']) ? $record['id'] : 0; unset($record['delete']); unset($record['id']); if ($del == 0) { $record['price'] = str_replace(',', '', $record['price']); if ($id > 0) { $record['id'] = $id; DB::table('roomtimes')->where('id', $id)->update($record); } else { DB::table('roomtimes')->insert($record); } } else { if ($id > 0) { DB::table('roomtimes')->where('id', '=', $id)->delete(); } } } foreach ($data_phutroi as $key => $record) { $del = isset($record['delete']) ? $record['delete'] : 0; $id = isset($record['id']) ? $record['id'] : 0; unset($record['delete']); unset($record['id']); if ($del == 0) { $record['price'] = str_replace(',', '', $record['price']); if ($id > 0) { $record['id'] = $id; DB::table('roomtimes')->where('id', $id)->update($record); } else { DB::table('roomtimes')->insert($record); } } else { if ($id > 0) { DB::table('roomtimes')->where('id', '=', $id)->delete(); } } } $roomprice = Roommoney::find($date_con['id']); if ($roomprice != null) { $roomprice->update($data_save); } else { $roommoney = Roommoney::create($data_save); } //$data = $data->toArray(); //return $data; print_r($data_phutroi); die; } }
public function save() { if (Request::ajax()) { $data = Request::all(); $date_con = json_decode($data['data'], true); $data_save = ['id' => $date_con['id'], 'roomtype_id' => $date_con['roomtype_id'], 'moc1' => $date_con['moc1'], 'moc2' => $date_con['moc2'], 'lamtron1' => $date_con['lamtron1'], 'lamtron2' => $date_con['lamtron2'], 'lamtron3' => $date_con['lamtron3'], 'gianguyenngay' => $date_con['gianguyenngay'], 'giatheogio' => $date_con['giatheogio'], 'tongsogio' => $date_con['tongsogio'], 'giaphutroi' => $date_con['giaphutroi']]; $roomprice = Roommoney::find($date_con['id']); if ($roomprice != null) { $roomprice->update($data_save); } else { $roommoney = Roommoney::create($data_save); } //$data = $data->toArray(); //return $data; print_r($data_save); die; } }