Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function savePhotoGiftDetails($data = array()){
- $status = false;
- App::import('Model','PhotogiftDetail');
- $this->PhotobookDetail = new PhotobookDetail;
- foreach( $data['PhotogiftDetail'] as $key => $detail ) {
- if( $detail['price'] == '' )
- unset($data['PhotogiftDetail'][$key]);
- }
- unset($key, $detail);
- $valid_product = $this->validates(array('Product'=> $data['Product']));
- if($valid_product) {
- $status = $this->save(array('Product' => $data['Product']));
- $saveDetail = false;
- if($status && !empty($data['PhotogiftDetail'])) {
- $details = array();
- $i = 0;
- foreach($data['PhotogiftDetail'] as $detail):
- $details[$i]['PhotogiftDetail']['product_id'] = $this->id;
- $details[$i]['PhotogiftDetail']['price'] = $detail['price'];
- $details[$i]['PhotogiftDetail']['description'] = $detail['description'];
- $i++;
- endforeach;
- $status = $this->PhotogiftDetail->saveAll($details);
- } else
- return $status;
- }
- return $status;
- }
Add Comment
Please, Sign In to add comment