当前位置: 首页>>代码示例>>PHP>>正文


PHP Property::findById方法代码示例

本文整理汇总了PHP中app\models\Property::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP Property::findById方法的具体用法?PHP Property::findById怎么用?PHP Property::findById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Property的用法示例。


在下文中一共展示了Property::findById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionIndex

 public function actionIndex($category_id = null)
 {
     $searchModel = new Category();
     $searchModel->active = 1;
     $params = Yii::$app->request->get();
     $dataProvider = $searchModel->search($params);
     $selectedCategory = null;
     if ($category_id !== null) {
         $selectedCategory = Category::findById($category_id);
     }
     if ($selectedCategory !== null) {
         if (Yii::$app->request->isPost === true) {
             $newProperty = isset($_GET['add_property_id']) ? Property::findById($_GET['add_property_id']) : null;
             if ($newProperty !== null) {
                 $filterSet = new FilterSets();
                 $filterSet->category_id = $selectedCategory->id;
                 $filterSet->property_id = $newProperty->id;
                 $filterSet->sort_order = 65535;
                 $filterSet->save();
             }
         }
     }
     $groups = PropertyGroup::getForObjectId(Object::getForClass(Product::className())->id, false);
     $propertiesDropdownItems = [];
     foreach ($groups as $group) {
         $item = ['label' => $group->name, 'url' => '#', 'items' => []];
         $properties = Property::getForGroupId($group->id);
         foreach ($properties as $prop) {
             $item['items'][] = ['label' => $prop->name, 'url' => '?category_id=' . $category_id . '&add_property_id=' . $prop->id, 'linkOptions' => ['class' => 'add-property-to-filter-set', 'data-property-id' => $prop->id, 'data-action' => 'post']];
         }
         $propertiesDropdownItems[] = $item;
     }
     return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'selectedCategory' => $selectedCategory, 'propertiesDropdownItems' => $propertiesDropdownItems]);
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:34,代码来源:FilterSetsController.php

示例2: run

 /**
  * Renders the widget.
  *
  * @return string
  */
 public function run()
 {
     if ($this->type == 'list') {
         $items = [];
         foreach ($this->model->options as $option) {
             $items[] = $option->name;
         }
         return $this->render($this->listView, ['items' => $items, 'model' => $this->model]);
     } else {
         $propertyGroup = Json::decode($this->model->option_generate)['group'];
         $items = [];
         $optionsJson = [];
         foreach ($this->model->options as $option) {
             $optionProperties = $option->getPropertyGroups()[$propertyGroup];
             $itemsJson = [];
             foreach ($optionProperties as $key => $property) {
                 foreach ($property->values as $name => $propValue) {
                     if (!isset($items[$key])) {
                         $items[$key] = ['name' => Property::findById($propValue['property_id'])->name];
                     }
                     if (!isset($firstOption)) {
                         $firstOption[$key] = $propValue['psv_id'];
                     }
                     $items[$key]['values'][$propValue['psv_id']] = $propValue['name'];
                     $itemsJson[$key] = $propValue['psv_id'];
                 }
             }
             $optionsJson[] = ['id' => $option->id, 'values' => $itemsJson, 'price' => $option->convertedPrice(), 'old_price' => $option->convertedPrice(null, true)];
         }
         return $this->render($this->formView, ['model' => $this->model, 'items' => $items, 'optionsJson' => $optionsJson]);
     }
 }
开发者ID:heartshare,项目名称:dotplant2,代码行数:37,代码来源:ProductOption.php

示例3: getNextPart

 /**
  * @inheritdoc
  */
 public function getNextPart($full_url, $next_part, &$previous_parts)
 {
     $property = Property::findById($this->property_id);
     if (is_null($property)) {
         return false;
     }
     if ($property->has_static_values && $property->has_slugs_in_values) {
         $cacheTags = [];
         $static_values = PropertyStaticValues::getValuesForPropertyId($this->property_id);
         $slugs = explode('/', $next_part);
         foreach ($static_values as $value) {
             if ($slugs[0] === $value['slug']) {
                 $this->parameters = ['properties' => [$this->property_id => [$value['id']]]];
                 if (!empty($value['title_append'])) {
                     $this->parameters['title_append'] = [$value['title_append']];
                 }
                 $cacheTags[] = ActiveRecordHelper::getObjectTag(PropertyStaticValues::className(), $value['id']);
                 $part = new self(['gathered_part' => $value['slug'], 'rest_part' => mb_substr($next_part, mb_strlen($value['slug'])), 'parameters' => $this->parameters, 'cacheTags' => $cacheTags]);
                 return $part;
             }
         }
         return false;
     } else {
         return false;
     }
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:29,代码来源:PropertyPart.php

示例4: run

 /**
  * @param null $property_id
  * @param null $handler_action
  * @param null $model_id
  * @return mixed
  */
 public function run($property_id = null, $handler_action = null, $model_id = null)
 {
     if (null === $handler_action || null === $property_id || null === $model_id) {
         return '';
     }
     $property = Property::findById($property_id);
     if (null === $property) {
         return '';
     }
     $actionParams = ['model_name' => $this->modelName, 'model_id' => $model_id, 'object_id' => $this->objectId, 'property' => $property];
     $propertyHandler = PropertyHandlers::createHandler($property->handler);
     return $propertyHandler->runAction($handler_action, $actionParams);
 }
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:19,代码来源:PropertyHandler.php

示例5: getGroupIdBypropertyId

 /**
  * Get property group id by property id
  * @param int $id property id
  * @return int property group id
  */
 private function getGroupIdBypropertyId($id)
 {
     foreach ($this->property_id_to_group_id as $groupId => $propertyIds) {
         if (in_array($id, $propertyIds)) {
             return $groupId;
         }
     }
     $property = Property::findById($id);
     if (!array_key_exists($property->property_group_id, $this->property_id_to_group_id)) {
         $this->property_id_to_group_id[$property->property_group_id] = [$id];
     } else {
         $this->property_id_to_group_id[$property->property_group_id][] = $id;
     }
     return intval($property->property_group_id);
 }
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:20,代码来源:HasProperties.php

示例6: getNextPart

 /**
  * @inheritdoc
  */
 public function getNextPart($full_url, $next_part, &$previous_parts)
 {
     $property = Property::findById($this->property_id);
     if (is_null($property)) {
         return false;
     }
     if ($property->has_static_values && $property->has_slugs_in_values) {
         $cacheTags = [];
         $static_values = PropertyStaticValues::getValuesForPropertyId($this->property_id);
         $slugs = explode('/', $next_part);
         $currentSlug = 0;
         $slugsCount = count($slugs);
         $appliedParts = [];
         foreach ($static_values as $value) {
             if ($slugs[$currentSlug] === $value['slug']) {
                 $appliedParts[] = $value['slug'];
                 if (isset($this->parameters['properties'][$this->property_id])) {
                     $this->parameters['properties'][$this->property_id][] = $value['id'];
                 } else {
                     $this->parameters = ['properties' => [$this->property_id => [$value['id']]]];
                 }
                 if (!empty($value['title_append'])) {
                     if ($value["title_prepend"] == 1) {
                         $this->addParam("title_prepend", $value["title_append"]);
                     } else {
                         $this->addParam("title_append", $value["title_append"]);
                     }
                 }
                 $cacheTags[] = ActiveRecordHelper::getObjectTag(PropertyStaticValues::className(), $value['id']);
                 $currentSlug++;
                 if ($currentSlug == $slugsCount) {
                     break;
                 }
             }
         }
         if ($currentSlug > 0) {
             $appliedPartsString = implode('/', $appliedParts);
             $part = new self(['gathered_part' => $appliedPartsString, 'rest_part' => mb_substr($next_part, mb_strlen($appliedPartsString)), 'parameters' => $this->parameters, 'cacheTags' => $cacheTags]);
             return $part;
         }
         return false;
     } else {
         return false;
     }
 }
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:48,代码来源:PropertyPart.php

示例7: filter

 public function filter(ActiveQuery $query, &$cacheKeyAppend)
 {
     $get = Yii::$app->request->post();
     if (isset($get['changeValue']) && is_array($get['changeValue'])) {
         foreach ($get['changeValue'] as $propertyId => $isActive) {
             if ($isActive && isset($get[$this->minValueAttribute][$propertyId]) && isset($get[$this->maxValueAttribute][$propertyId]) && is_numeric($get[$this->minValueAttribute][$propertyId]) && is_numeric($get[$this->maxValueAttribute][$propertyId])) {
                 $property = Property::findById($propertyId);
                 if ($property->has_static_values) {
                     $query->innerJoin('{{%object_static_values}} as osvf' . $propertyId, '{{%product}}.id=osvf' . $propertyId . '.object_model_id');
                     $query->innerJoin('{{%property_static_values}} as psvf' . $propertyId, 'psvf' . $propertyId . '.id=osvf' . $propertyId . '.property_static_value_id');
                     $query->andWhere('psvf' . $propertyId . '.value >= :minData ')->andWhere('psvf' . $propertyId . '.value <= :maxData ')->andWhere(['psvf' . $propertyId . '.property_id' => $propertyId])->addParams([':minData' => (int) $get[$this->minValueAttribute][$propertyId], ':maxData' => (int) $get[$this->maxValueAttribute][$propertyId]]);
                 } elseif ($property->is_eav) {
                     $query->innerJoin('{{%product_eav}} as peav' . $propertyId, '{{%product}}.id=peav' . $propertyId . '.object_model_id');
                     $query->andWhere(['peav' . $propertyId . '.property_group_id' => $property->property_group_id, 'peav' . $propertyId . '.key' => $property->key]);
                     $query->andWhere(['>=', 'peav' . $propertyId . '.value', (int) $get[$this->minValueAttribute][$propertyId]]);
                     $query->andWhere(['<=', 'peav' . $propertyId . '.value', (int) $get[$this->maxValueAttribute][$propertyId]]);
                 }
                 $cacheKeyAppend .= 'FilterRangeProperty:propertyId' . $propertyId . ':[min:' . (int) $get[$this->minValueAttribute][$propertyId] . ':max' . (int) $get[$this->maxValueAttribute][$propertyId] . ']';
             }
         }
     }
     return $query;
 }
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:23,代码来源:FilterRangeProperty.php

示例8: actionEditProperty

 public function actionEditProperty($property_group_id, $id = null)
 {
     if ($id === null) {
         $model = new Property();
         $model->handler_additional_params = '[]';
     } else {
         $model = Property::findById($id);
     }
     $object = Object::getForClass(Property::className());
     $model->property_group_id = $property_group_id;
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         $propertyHandler = PropertyHandlers::createHandler($model->handler);
         if (!$propertyHandler->changePropertyType($model)) {
             if ($model->is_column_type_stored) {
                 if ($model->isNewRecord) {
                     $object = Object::findById($model->group->object_id);
                     Yii::$app->db->createCommand()->addColumn($object->column_properties_table_name, $model->key, "TINYTEXT")->execute();
                     if ($object->object_class == Form::className()) {
                         $submissionObject = Object::getForClass(Submission::className());
                         $col_type = $this->getColumnType($model->value_type);
                         Yii::$app->db->createCommand()->addColumn($submissionObject->column_properties_table_name, $model->key, $col_type)->execute();
                     }
                 } else {
                     if ($model->key != $model->getOldAttribute('key')) {
                         $object = Object::findById($model->group->object_id);
                         Yii::$app->db->createCommand()->renameColumn($object->column_properties_table_name, $model->getOldAttribute('key'), $model->key)->execute();
                         if ($object->object_class == Form::className()) {
                             $submissionObject = Object::getForClass(Submission::className());
                             Yii::$app->db->createCommand()->renameColumn($submissionObject->column_properties_table_name, $model->getOldAttribute('key'), $model->key)->execute();
                         }
                     }
                     if ($model->value_type != $model->getOldAttribute('value_type')) {
                         $object = Object::findById($model->group->object_id);
                         $new_type = $this->getColumnType($model->value_type);
                         Yii::$app->db->createCommand()->alterColumn($object->column_properties_table_name, $model->getOldAttribute('key'), $new_type)->execute();
                         if ($object->object_class == Form::className()) {
                             $submissionObject = Object::getForClass(Submission::className());
                             Yii::$app->db->createCommand()->renameColumn($submissionObject->column_properties_table_name, $model->getOldAttribute('key'), $new_type)->execute();
                         }
                     }
                 }
             }
         }
         $save_result = $model->save();
         if ($save_result) {
             $this->runAction('save-info');
             Yii::$app->session->setFlash('success', Yii::t('app', 'Record has been saved'));
             $returnUrl = Yii::$app->request->get('returnUrl', ['/backend/properties/group', 'id' => $property_group_id]);
             switch (Yii::$app->request->post('action', 'save')) {
                 case 'next':
                     return $this->redirect(['/backend/properties/edit-property', 'property_group_id' => $property_group_id, 'returnUrl' => $returnUrl]);
                 case 'back':
                     return $this->redirect($returnUrl);
                 default:
                     return $this->redirect(Url::toRoute(['/backend/properties/edit-property', 'id' => $model->id, 'property_group_id' => $model->property_group_id, 'returnUrl' => $returnUrl]));
             }
         } else {
             Yii::$app->session->setFlash('error', Yii::t('app', 'Cannot save data'));
         }
     }
     $searchModel = new PropertyStaticValues();
     $searchModel->property_id = $model->id;
     $dataProvider = $searchModel->search($_GET);
     return $this->render('edit-property', ['model' => $model, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'fieldinterpretParentId' => 0, 'object' => $object]);
 }
开发者ID:ar7n,项目名称:dotplant2,代码行数:65,代码来源:PropertiesController.php

示例9: updateValues

 public function updateValues($new_values, $object_id, $object_model_id)
 {
     $column_type_updates = ['object_model_id' => $object_model_id];
     $osv_psv_ids = [];
     $new_eav_values = [];
     $eav_ids_to_delete = [];
     foreach ($new_values as $key => $values) {
         $property = Property::findById($values->property_id);
         if ($property->captcha == 1) {
             continue;
         }
         if (!isset($this->values_by_property_key[$key])) {
             // нужно добавить
             if ($property->is_column_type_stored) {
                 $column_type_updates[$key] = (string) $values;
             } elseif ($property->has_static_values) {
                 foreach ($values->values as $val) {
                     $osv_psv_ids[] = $val['value'];
                 }
             } elseif ($property->is_eav) {
                 $new_eav_values[$key] = $values;
             }
         } else {
             if ($property->is_column_type_stored) {
                 $column_type_updates[$key] = (string) $values;
             } elseif ($property->has_static_values) {
                 foreach ($values->values as $val) {
                     $osv_psv_ids[] = $val['value'];
                 }
             } elseif ($property->is_eav) {
                 // добавим новые
                 foreach ($values->values as $val) {
                     $exist_in_old = false;
                     foreach ($this->values_by_property_key[$key]->values as $old_val) {
                         if ($old_val['value'] == $val['value']) {
                             $exist_in_old = true;
                             break;
                         }
                     }
                     if ($exist_in_old == false) {
                         $new_eav_values[] = [$object_model_id, $values->property_group_id, $key, $val['value'], 0];
                     }
                 }
                 // теперь добавим на удаление
                 foreach ($this->values_by_property_key[$key]->values as $old_val) {
                     $exist_in_new = false;
                     foreach ($values->values as $new_val) {
                         if ($old_val['value'] == $new_val['value']) {
                             $exist_in_new = true;
                             break;
                         }
                     }
                     if ($exist_in_new == false) {
                         // @todo find why sometimes it isn't exist
                         if (isset($old_val['eav_id'])) {
                             $eav_ids_to_delete[] = $old_val['eav_id'];
                         }
                     }
                 }
             }
         }
     }
     $osv_psv_ids_to_delete = [];
     foreach ($this->values_by_property_key as $key => $values) {
         $property = Property::findById($values->property_id);
         if (in_array($key, array_keys($new_values)) === false) {
             // if in incoming array there was no specification for this property - skip it
             continue;
         }
         if ($property->has_static_values) {
             foreach ($values->values as $val) {
                 if (in_array($val['psv_id'], $osv_psv_ids) === false) {
                     // в новых значениях нет
                     $osv_psv_ids_to_delete[] = $val['psv_id'];
                 } else {
                     // удалим, чтобы заново не добавлять
                     unset($osv_psv_ids[array_search($val['psv_id'], $osv_psv_ids)]);
                 }
             }
         }
     }
     if (count($osv_psv_ids_to_delete) > 0) {
         ObjectStaticValues::deleteAll(['and', '`object_id` = :objectId', ['and', '`object_model_id` = :objectModelId', ['in', '`property_static_value_id`', $osv_psv_ids_to_delete]]], [':objectId' => $object_id, ':objectModelId' => $object_model_id]);
     }
     if (count($osv_psv_ids) > 0) {
         $rows = [];
         foreach ($osv_psv_ids as $psv_id) {
             // 0 - Not Selected Field. Такие значения в базу не сохраняем
             if ($psv_id == 0) {
                 continue;
             }
             $rows[] = [$object_id, $object_model_id, $psv_id];
         }
         if (!empty($rows)) {
             Yii::$app->db->createCommand()->batchInsert(ObjectStaticValues::tableName(), ['object_id', 'object_model_id', 'property_static_value_id'], $rows)->execute();
         }
     }
     Yii::$app->cache->delete("PSV:" . $object_id . ":" . $object_model_id);
     if (count($column_type_updates) > 1) {
         $table_name = Object::findById($object_id)->column_properties_table_name;
//.........这里部分代码省略.........
开发者ID:Jamshid90,项目名称:dotplant2,代码行数:101,代码来源:AbstractModel.php

示例10: foreach

                                    </td>
                                    <td>
                                        <?php 
        echo Yii::t('app', 'Actions');
        ?>
                                    </td>
                                </tr>
                            </thead>
                            <tbody class="properties-body">
                                <?php 
        foreach ($sets as $filterSet) {
            ?>
                                    <?php 
            /** @var \app\modules\shop\models\FilterSets $filterSet */
            $rowClass = $filterSet->category_id === $selectedCategory->id ? $filterSet->delegate_to_children === 1 ? 'success' : '' : 'info';
            $property = \app\models\Property::findById($filterSet->property_id);
            ?>
                                    <tr class="<?php 
            echo $rowClass;
            ?>
" property-id="<?php 
            echo $property->id;
            ?>
" filterset-id="<?php 
            echo $filterSet->id;
            ?>
">
                                        <td class="td-no-padding">
                                            <span class="sort-handle">
                                                <?php 
            echo Icon::show('arrows-v');
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:31,代码来源:index.php

示例11: beforeDelete

 public function beforeDelete()
 {
     if (null !== ($parent = Property::findById($this->property_id))) {
         $parent->invalidateModelCache();
     }
     return parent::beforeDelete();
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:7,代码来源:PropertyStaticValues.php

示例12: appendPropertiesFilters

 /**
  * Добавляет к запросу фильтры по свойствам
  * @param $object Object
  * @param $query ActiveQuery
  * @param $values_by_property_id array
  * @param array $dynamic_values_by_property_id array
  * @throws \Exception
  */
 public static function appendPropertiesFilters($object, &$query, $values_by_property_id, $dynamic_values_by_property_id = [])
 {
     /** @avr $object Object */
     // сначала сгруппируем свойства по типу хранения
     $by_storage = ['eav' => [], 'table_inheritance' => [], 'static_values' => []];
     $dynamic_by_storage = ['eav' => [], 'table_inheritance' => []];
     foreach ($values_by_property_id as $property_id => $values) {
         // values может быть просто строкой(одно значение), а может уже прийти массивом
         $values = (array) $values;
         $property = Property::findById($property_id);
         if ($property === null) {
             continue;
         }
         if ($property->is_eav) {
             $by_storage['eav'][] = ['property' => $property, 'values' => $values];
         } elseif ($property->is_column_type_stored) {
             $by_storage['table_inheritance'][] = ['property' => $property, 'values' => $values];
         } elseif ($property->has_static_values) {
             $by_storage['static_values'][] = ['property' => $property, 'values' => $values];
         } else {
             throw new \Exception("Wrong property type for " . $property->id);
         }
     }
     foreach ($dynamic_values_by_property_id as $property_id => $values) {
         $property = Property::findById($property_id);
         if ($property) {
             if ($property->is_eav) {
                 $dynamic_by_storage['eav'][] = ['property' => $property, 'values' => $values];
             } elseif ($property->is_column_type_stored) {
                 $dynamic_by_storage['table_inheritance'][] = ['property' => $property, 'values' => $values];
             } else {
                 throw new \Exception("Wrong property type for " . $property->id);
             }
         }
     }
     $join_counter = 1;
     $ti_clauses = [];
     $join_table_name = "PropertiesJoinTable" . $join_counter++;
     foreach ($by_storage['table_inheritance'] as $item) {
         $property = $item['property'];
         $or_clauses = [];
         foreach ($item['values'] as $val) {
             $or_clauses[] = "{$join_table_name}." . Yii::$app->db->quoteColumnName($property->key) . " = " . Yii::$app->db->quoteValue($val);
         }
         $ti_clauses[] = implode(" OR ", $or_clauses);
     }
     foreach ($dynamic_by_storage['table_inheritance'] as $item) {
         $property = $item['property'];
         $clauses = [];
         if (isset($item['values']['min']) && strlen($item['values']['min'])) {
             $clauses[] = "{$join_table_name}." . Yii::$app->db->quoteColumnName($property->key) . " >= " . Yii::$app->db->quoteValue((double) $item['values']['min']);
         }
         if (isset($item['values']['max']) && strlen($item['values']['max'])) {
             $clauses[] = "{$join_table_name}." . Yii::$app->db->quoteColumnName($property->key) . " <= " . Yii::$app->db->quoteValue((double) $item['values']['max']);
         }
         if (!empty($clauses)) {
             $ti_clauses[] = '(' . implode(" AND ", $clauses) . ')';
         }
     }
     if (count($ti_clauses) > 0) {
         $ti_clauses = implode(" AND ", $ti_clauses);
         $query = $query->innerJoin($object->column_properties_table_name . " {$join_table_name}", "{$join_table_name}.object_model_id = " . Yii::$app->db->quoteTableName($object->object_table_name) . ".id " . " AND " . $ti_clauses);
     }
     if (count($by_storage['static_values'])) {
         foreach ($by_storage['static_values'] as $item) {
             $joinTableName = 'OSVJoinTable' . $item['property']->id;
             if (count($item['values']) > 0) {
                 $query = $query->innerJoin(ObjectStaticValues::tableName() . " " . $joinTableName, "{$joinTableName}.object_id = " . intval($object->id) . " AND {$joinTableName}.object_model_id = " . Yii::$app->db->quoteTableName($object->object_table_name) . ".id ");
                 $query = $query->andWhere(new Expression('`' . $joinTableName . '`.`property_static_value_id` in (' . implode(', ', array_map('intval', $item['values'])) . ')'));
             }
         }
     }
     if (count($by_storage['eav'])) {
         foreach ($by_storage['eav'] as $item) {
             $joinTableName = 'EAVJoinTable' . $item['property']->id;
             if (count($item['values']) > 0) {
                 $query = $query->innerJoin($object->eav_table_name . " " . $joinTableName, "{$joinTableName}.object_model_id = " . Yii::$app->db->quoteTableName($object->object_table_name) . ".id ");
                 $query = $query->andWhere(new Expression('`' . $joinTableName . '`.`value` in (' . implode(', ', array_map('intval', $item['values'])) . ') AND `' . $joinTableName . '`.`key` = "' . $item['property']->key . '"'));
             }
         }
     }
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:90,代码来源:PropertiesHelper.php

示例13: foreach

     }
 }
 $checkboxes = [];
 foreach ($select as $value) {
     if ($hide_others) {
         if ($dont_hide_value_id != $value['id']) {
             continue;
         }
     }
     $options = ['class' => 'filter-select '];
     $params = [$route];
     $params += $current_selections;
     $params['category_group_id'] = $category_group_id;
     foreach ($possible_selections as $u_group_id => $u_item) {
         foreach ($u_item['static_selections'] as $u_property_id => $select) {
             if (Property::findById($u_property_id)->depends_on_property_id == $property_id) {
                 unset($params['properties'][$u_property_id]);
             }
         }
     }
     $active = false;
     if (isset($params['properties'][$property_id]) && is_array($params['properties'][$property_id])) {
         if (in_array($value['id'], $params['properties'][$property_id])) {
             $options['class'] .= 'active';
             $active = true;
         }
     }
     $params['properties'][$property_id] = [$value['id']];
     $disabled = in_array($value['id'], $disabled_ids);
     $disabled_array = $disabled ? ['disabled' => 'disabled'] : [];
     $label = $value['name'];
开发者ID:yii2ApplicationCollect,项目名称:dotplant2,代码行数:31,代码来源:filter-form.php

示例14: columns

 public function columns($baseModelColumns)
 {
     $columns = $baseModelColumns;
     foreach ($this->propertyGroups as $groupId => $properties) {
         foreach ($properties as $key => $propertyValue) {
             /** @var PropertyValue $propertyValue */
             $prop = Property::findById($propertyValue->property_id);
             if ($prop->has_static_values) {
                 $column = ['value' => function ($model) use($prop) {
                     return $model->property($prop->key);
                 }, 'filter' => PropertyStaticValues::getSelectForPropertyId($propertyValue->property_id)];
             } elseif ($prop->property_handler_id === 3) {
                 $column = ['value' => function ($model) use($prop) {
                     return $model->property($prop->key);
                 }, 'filter' => [0 => Yii::t('app', 'No'), 1 => Yii::t('app', 'Yes')]];
             } else {
                 $column = ['value' => function ($model) use($prop) {
                     return $model->property($prop->key);
                 }];
             }
             $column = ArrayHelper::merge($column, ['header' => $prop->name, 'attribute' => $prop->key, 'enableSorting' => true]);
             $columns[] = $column;
         }
     }
     return $columns;
 }
开发者ID:yii2ApplicationCollect,项目名称:dotplant2,代码行数:26,代码来源:DynamicSearchModel.php

示例15: foreach

    <?php 
foreach ($availablePropertyGroups as $id => $properties) {
    ?>
        <?php 
    $propertyGroup = \app\models\PropertyGroup::findById($id);
    ?>
        <fieldset class="property-group">
            <legend><?php 
    echo Html::encode($propertyGroup->name);
    ?>
</legend>

            <?php 
    foreach ($properties as $key => $propertyValue) {
        echo '<div class="well well-sm well-light"><b>' . \app\models\Property::findById($propertyValue->property_id)->name . ' (<small>' . $key . '</small>)' . '</b>';
        $prefix = 'fields[property][' . $propertyValue->property_id . '][';
        echo $form->field($model, $prefix . 'enabled]')->checkbox(['label' => Yii::t('app', 'Process')]);
        $property = \app\models\Property::findById($propertyValue->property_id);
        if ($property->has_static_values) {
            echo $form->field($model, $prefix . 'processValuesAs]')->dropDownList(['text' => Yii::t('app', 'Text representation'), 'id' => 'id ' . Yii::t('app', '(static value record id)'), 'value' => Yii::t('app', 'Value representation')])->label(Yii::t('app', 'Process values as:'));
        }
        echo Html::activeHiddenInput($model, $prefix . 'key]', ['value' => $key]);
        echo '</div><br>';
    }
    ?>
        </fieldset>
    <?php 
}
?>
</fieldset>
开发者ID:yii2ApplicationCollect,项目名称:dotplant2,代码行数:30,代码来源:_propertyFields.php


注:本文中的app\models\Property::findById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。