private function saveProduction(Deal $model)
 {
     $deal = isset($_POST['Deal']) ? $_POST['Deal'] : false;
     $features = isset($deal['feature']) ? array_keys($deal['feature']) : [];
     $hasErrors = false;
     if ($deal) {
         $model->attributes = $deal;
         if (isset($_POST['textCustomFeature']) && $_POST['textCustomFeature']) {
             $customFeature = $this->createCustomFeature($_POST['textCustomFeature']);
             if ($customFeature->save()) {
                 $features[] = $customFeature->fea_id;
             } else {
                 Yii::app()->user->setFlash('custom-feature-error', 'Custom feature could not be saved. Contact administrator');
                 $hasErrors = true;
             }
         }
         if (!$model->setFeatures($features)) {
             Yii::app()->user->setFlash('feature-error', 'Features could not be updated');
             $hasErrors = true;
         }
         if (isset($deal['video']) && $deal['video']) {
             $this->saveVideo($model->dea_id, $deal['video']);
         }
         /**
          * taking advantage of lazy operators. We first validate (to get all validation errors.
          * Then if there were none we check if something happened before, like custom feature was not saved.
          * finaly if there were no errors before we save the model.
          */
         if ($model->validate() && !$hasErrors && $model->save()) {
             return true;
         }
     }
     return false;
 }