/**
  * @return \yii\db\ActiveQuery
  */
 public function getPresentationActionPropertyValues()
 {
     return $this->hasMany(PresentationActionPropertyValues::className(), ['id' => 'property_value_id']);
 }
 protected function savePresentationActionProperties($model, $user, $service, $model_action_properties)
 {
     if ($model and $user and $service and $model_action_properties) {
         if ($model->save()) {
             // Presentation Object Properties
             if ($model_action_properties) {
             }
             // Presentation Methods
             if ($model_action_properties) {
                 if ($model->provider_presentation_action_properties && $model->provider_presentation_action_properties != '') {
                     $existPres = $this->findModel($model->provider_presentation_action_properties);
                     if ($existPresentationActionProperties = $existPres->presentationActionProperties) {
                         foreach ($existPresentationActionProperties as $existPresentationActionProperty) {
                             $model_action_property = new PresentationActionProperties();
                             $model_action_property->presentation_id = $model->id;
                             $model_action_property->action_property_id = $existPresMethod->action_property_id;
                             $model_action_property->value = $existPresMethod->value;
                             $model_action_property->value_max = $existPresMethod->value_max;
                             $model_action_property->value_operator = $existPresMethod->value_operator;
                             $model_action_property->multiple_values = $existPresMethod->multiple_values;
                             $model_action_property->read_only = $existPresMethod->read_only;
                             $model_action_property->save();
                             if ($existPresentationActionPropertyValues = $existPresentationActionProperty->presentationActionPropertyVaules) {
                                 foreach ($existPresentationActionPropertyValues as $key => $existPresentationActionPropertyValue) {
                                     $new_meth_model[$key] = new PresentationActionPropertyValues();
                                     $new_meth_model[$key]->presentation_action_property_id = $model_action_property->id;
                                     $new_meth_model[$key]->property_value_id = $existPresentationActionPropertyValue->property_value_id;
                                     $new_meth_model[$key]->save();
                                 }
                             }
                         }
                     }
                 } else {
                     if (Model::loadMultiple($model_action_properties, Yii::$app->request->post())) {
                         foreach ($model_action_properties as $model_action_property) {
                             $model_action_property->presentation_id = $model->id;
                             $model_action_property->multiple_values = $model_action_property['actionPropertyValues'] != null ? 1 : 0;
                             if ($model_action_property->save()) {
                                 if ($model_action_property['actionPropertyValues'] != null) {
                                     if (is_array($model_action_property['actionPropertyValues'])) {
                                         foreach ($model_action_property['actionPropertyValues'] as $key => $model_action_property_value) {
                                             $new_method_model[$key] = new PresentationActionPropertyValues();
                                             $new_method_model[$key]->presentation_action_property_id = $model_action_property->id;
                                             $new_method_model[$key]->property_value_id = $model_action_property_value;
                                             $new_method_model[$key]->save();
                                         }
                                     } else {
                                         $new_method_model = new PresentationActionPropertyValues();
                                         $new_method_model->presentation_action_property_id = $model_action_property->id;
                                         $new_method_model->property_value_id = $model_action_property['actionPropertyValues'];
                                         $new_method_model->save();
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             echo '<pre>';
             print_r($model);
             die;
         }
     }
     return false;
 }
 public function getPresentationActionPropertyValues()
 {
     return $this->hasMany(PresentationActionPropertyValues::className(), ['presentation_action_property_id' => 'id'])->viaTable('presentation_action_properties', ['presentation_id' => 'id']);
 }