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


PHP Attribute::model方法代码示例

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


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

示例1: run

 /**
  * @throws Exception
  */
 public function run()
 {
     if ('*' === $this->attributes) {
         $this->attributes = Attribute::model()->with(['options.parent'])->cache($this->cacheTime)->findAll(['condition' => 't.is_filter = 1', 'order' => 't.sort DESC']);
     }
     foreach ($this->attributes as $attribute) {
         $model = is_string($attribute) ? Attribute::model()->findByAttributes(['name' => $attribute]) : $attribute;
         if ($model) {
             switch ($model->type) {
                 case Attribute::TYPE_DROPDOWN:
                     $this->widget('application.modules.store.widgets.filters.DropdownFilterWidget', ['attribute' => $model]);
                     break;
                 case Attribute::TYPE_CHECKBOX_LIST:
                     $this->widget('application.modules.store.widgets.filters.DropdownFilterWidget', ['attribute' => $model]);
                     break;
                 case Attribute::TYPE_CHECKBOX:
                     $this->widget('application.modules.store.widgets.filters.CheckboxFilterWidget', ['attribute' => $model]);
                     break;
                 case Attribute::TYPE_NUMBER:
                     $this->widget('application.modules.store.widgets.filters.NumberFilterWidget', ['attribute' => $model]);
                     break;
                 case Attribute::TYPE_SHORT_TEXT:
                     $this->widget('application.modules.store.widgets.filters.TextFilterWidget', ['attribute' => $model]);
                     break;
             }
         }
     }
 }
开发者ID:syrexby,项目名称:domovoishop.by,代码行数:31,代码来源:AttributesFilterWidget.php

示例2: loadModel

 public function loadModel($id)
 {
     if (($model = Attribute::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
开发者ID:kuzmina-mariya,项目名称:happy-end,代码行数:7,代码来源:AttributeBackendController.php

示例3: safeUp

 public function safeUp()
 {
     $this->createTable('{{store_product_attribute_value}}', ['id' => 'pk', 'product_id' => 'INTEGER NOT NULL', 'attribute_id' => 'INTEGER NOT NULL', 'number_value' => 'REAL', 'string_value' => 'VARCHAR(250)', 'text_value' => 'TEXT', 'option_value' => 'INTEGER', 'create_time' => 'DATETIME'], $this->getOptions());
     //fk
     $this->addForeignKey('{{fk_product_attribute_product}}', '{{store_product_attribute_value}}', 'product_id', '{{store_product}}', 'id', 'CASCADE');
     $this->addForeignKey('{{fk_product_attribute_attribute}}', '{{store_product_attribute_value}}', 'attribute_id', '{{store_attribute}}', 'id', 'CASCADE');
     $this->addForeignKey('{{fk_product_attribute_option}}', '{{store_product_attribute_value}}', 'option_value', '{{store_attribute_option}}', 'id', 'CASCADE');
     //ix
     $this->createIndex('{{ix_product_attribute_number_value}}', '{{store_product_attribute_value}}', 'number_value');
     $this->createIndex('{{ix_product_attribute_string_value}}', '{{store_product_attribute_value}}', 'string_value');
     //перенести аттрибуты
     $attributes = Yii::app()->getDb()->createCommand('SELECT * FROM {{store_product_attribute_eav}}')->queryAll();
     $modelsAttr = [];
     foreach ($attributes as $attribute) {
         $product = Product::model()->findByPk($attribute['product_id']);
         if (null === $product) {
             continue;
         }
         if (!isset($modelsAttr[$attribute['attribute']])) {
             $model = Attribute::model()->find('name = :name', [':name' => $attribute['attribute']]);
             if (null === $model) {
                 continue;
             }
             $modelsAttr[$attribute['attribute']] = $model;
         }
         $value = new AttributeValue();
         $value->store($modelsAttr[$attribute['attribute']]->id, $attribute['value'], $product);
     }
     $this->dropTable('{{store_product_attribute_eav}}');
 }
开发者ID:alextravin,项目名称:yupe,代码行数:30,代码来源:m150907_084604_new_attributes.php

示例4: getPolicy

 public function getPolicy()
 {
     $att = Attribute::model()->findByAttributes(array('attribute_name' => Attribute::FUP));
     if (!$att) {
         return null;
     }
     return DatasetAttributes::model()->findByAttributes(array('dataset_id' => $this->id, 'attribute_id' => $att->id));
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:8,代码来源:Dataset.php

示例5: getPlaceList

 public function getPlaceList()
 {
     // Выборка списка мест
     $placeCategory = AttributeCategory::model()->find('t.code = :code', array(':code' => AttributeCategory::PLACES_CATEGORY_CODE));
     $places = Attribute::model()->category($placeCategory->id)->sortByCode()->findAll();
     return CHtml::listData($places, 'code', function ($data) {
         return $data->code . ' - ' . $data->title;
     });
 }
开发者ID:kuzmina-mariya,项目名称:happy-end,代码行数:9,代码来源:TableDescription.php

示例6: init

 /**
  * @throws Exception
  */
 public function init()
 {
     if (is_string($this->attribute)) {
         $this->attribute = Attribute::model()->findByAttributes(['name' => $this->attribute]);
     }
     if (!$this->attribute instanceof Attribute || !$this->attribute->isMultipleValues()) {
         throw new Exception(Yii::t('StoreModulle.store', 'Attribute error!'));
     }
     parent::init();
 }
开发者ID:yupe,项目名称:yupe,代码行数:13,代码来源:DropdownFilterWidget.php

示例7: init

 public function init()
 {
     if (is_string($this->attribute)) {
         $this->attribute = Attribute::model()->findByAttributes(['name' => $this->attribute]);
     }
     if (!$this->attribute instanceof Attribute || $this->attribute->type != Attribute::TYPE_NUMBER) {
         throw new Exception('Атрибут не найден или неправильного типа');
     }
     parent::init();
 }
开发者ID:RonLab1987,项目名称:43berega,代码行数:10,代码来源:NumberFilterWidget.php

示例8: init

 public function init()
 {
     parent::init();
     // Выборка категорий/атрибутов
     $this->categoriesA = AttributeCategory::model()->is_a()->with('attrs')->findAll();
     $this->categoriesB = AttributeCategory::model()->is_b()->with('attrs')->findAll();
     // Выборка списка мест
     $placeCategory = AttributeCategory::model()->find('t.code = :code', array(':code' => AttributeCategory::PLACES_CATEGORY_CODE));
     $this->places = Attribute::model()->category($placeCategory->id)->sortByCode()->findAll();
     $this->operations = array('and' => 'и присутствует', 'and_not' => 'и отсутствует', 'or' => 'или');
     $this->cells = array('sameСell' => 'Та же ячейка', 'anotherOpenCellInSameColumn' => 'Другая открытая ячейка в том же столпе', 'rightAndLeftCells' => 'Ячейки, стоящие справа и слева', 'notRightAndLeftCells' => 'Любая ячейка, кроме стоящих непосредственно слева и справа', 'anotherCell' => 'Любая другая ячейка', 'destinyPillars' => 'Столпы судьбы', 'currentLuckPillar' => 'Текущий столп удачи', 'eventPillars' => 'Столпы рассматриваемой даты');
 }
开发者ID:kuzmina-mariya,项目名称:happy-end,代码行数:12,代码来源:AnalyzerResultBackendController.php

示例9: actionAttribute

 function actionAttribute($id = null)
 {
     if ($id == null) {
         $this->render('attributes', array('attributes' => Attribute::model()->findAll()));
     } else {
         $c = Attribute::model()->findByPk($id);
         if ($c == null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
         $this->render('attribute', array('attribute' => $c));
     }
 }
开发者ID:black2279,项目名称:Tracy-openshift,代码行数:12,代码来源:SpellCheckController.php

示例10: actionSort

 public function actionSort()
 {
     if (isset($_POST['items']) && is_array($_POST['items'])) {
         $i = 0;
         foreach ($_POST['items'] as $item) {
             $project = Attribute::model()->findByPk($item);
             $project->sort_order = $i;
             $project->save();
             $i++;
         }
     }
 }
开发者ID:Rudianasaja,项目名称:cycommerce,代码行数:12,代码来源:AttributeController.php

示例11: actionUpdate

 /**
  * @param $id
  * @throws CHttpException
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if (($data = Yii::app()->getRequest()->getPost('Type')) !== null) {
         $model->setAttributes($data);
         if ($model->save() && $model->storeTypeAttributes(Yii::app()->getRequest()->getPost('attributes', []))) {
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('StoreModule.store', 'Product type is updated'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
         }
     }
     $criteria = new CDbCriteria();
     $criteria->addNotInCondition('id', CHtml::listData($model->attributeRelation, 'attribute_id', 'attribute_id'));
     $availableAttributes = Attribute::model()->findAll($criteria);
     $this->render('update', ['model' => $model, 'availableAttributes' => $availableAttributes]);
 }
开发者ID:alextravin,项目名称:yupe,代码行数:19,代码来源:TypeBackendController.php

示例12: getForCategory

 /**
  * @param StoreCategory $category
  * @return Attribute[]
  */
 public function getForCategory(StoreCategory $category)
 {
     $criteria = new CDbCriteria(['condition' => 't.is_filter = 1 AND t.type != :type', 'params' => [':type' => Attribute::TYPE_TEXT], 'join' => 'LEFT JOIN {{store_type_attribute}} ON t.id = {{store_type_attribute}}.attribute_id
                    LEFT JOIN {{store_type}} ON {{store_type_attribute}}.type_id = {{store_type}}.id
                    LEFT JOIN {{store_product}} AS products ON products.type_id = {{store_type}}.id', 'distinct' => true]);
     $categories = $category->getChildsArray();
     if (!empty($categories)) {
         $categoriesCriteria = new CDbCriteria(['condition' => 'products.category_id = :category', 'params' => [':category' => $category->id]]);
         $categoriesCriteria->addInCondition('products.category_id', $categories, 'OR');
         $criteria->mergeWith($categoriesCriteria, 'AND');
     } else {
         $criteria->addCondition('products.category_id = :category');
         $criteria->params[':category'] = $category->id;
     }
     return Attribute::model()->findAll($criteria);
 }
开发者ID:yupe,项目名称:yupe,代码行数:20,代码来源:AttributesRepository.php

示例13: actionUpdate

 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (($data = Yii::app()->getRequest()->getPost('Type')) !== null) {
         $model->setAttributes($data);
         $model->categories = serialize(Yii::app()->getRequest()->getPost('categories'));
         if ($model->save()) {
             $model->setTypeAttributes(Yii::app()->getRequest()->getPost('attributes'));
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('StoreModule.type', 'Тип обновлен.'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
         }
     }
     $criteria = new CDbCriteria();
     $criteria->addNotInCondition('id', CHtml::listData($model->attributeRelation, 'attribute_id', 'attribute_id'));
     $availableAttributes = Attribute::model()->findAll($criteria);
     $this->render('update', ['model' => $model, 'availableAttributes' => $availableAttributes]);
 }
开发者ID:RonLab1987,项目名称:43berega,代码行数:19,代码来源:TypeBackendController.php

示例14: actionCreate

 public function actionCreate()
 {
     $model = new DatasetAttributes();
     $att = Attribute::model()->findByAttributes(array('attribute_name' => Attribute::FUP));
     if (!$att) {
         $att = new Attribute();
         $att->attribute_name = Attribute::FUP;
         $att->definition = '';
         $att->save();
     }
     $model->attribute_id = $att->id;
     $image = new Images();
     if (isset($_POST['DatasetAttributes'])) {
         $args = $_POST['DatasetAttributes'];
         $exist = DatasetAttributes::model()->findByAttributes(array('dataset_id' => $args['dataset_id'], 'attribute_id' => $att->id));
         if ($exist) {
             $model = $exist;
         }
         $model->attributes = $args;
         $model->value = '';
         //$image->attributes = $_POST['Images'];
         $image->license = "no license";
         $image->photographer = "no author";
         $image->source = "gigadb";
         if ($image->validate()) {
             $image->save();
         } else {
             Yii::log(print_r($image->getErrors(), true), 'debug');
         }
         if ($image) {
             $model->image_id = $image->id;
         }
         if ($model->validate()) {
             $model->save();
             $this->redirect('/dataset/' . $model->dataset->identifier);
         } else {
             Yii::log(print_r($model->getErrors(), true), 'debug');
         }
     }
     $this->render('create', array('model' => $model, 'image' => $image));
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:41,代码来源:PolicyController.php

示例15: save

 public function save()
 {
     $attribute = Attribute::model()->findByPk($this->id);
     if (is_null($attribute)) {
         // is insert
         $attribute = new Attribute();
         $attribute->attribute_group_id = $this->group;
         $attribute->sort_order = $this->sortOrder;
         $attribute->save();
         $attributeDescription = new AttributeDescription();
         $attributeDescription->attribute_id = $attribute->attribute_id;
         $attributeDescription->language_id = 1;
         // TODO: read locale
         $attributeDescription->name = $this->name;
         $attributeDescription->save();
     } else {
         $attribute->attribute_group_id = $this->group;
         $attribute->sort_order = $this->sortOrder;
         $attribute->save();
         $attribute->description->name = $this->name;
         $attribute->description->save();
     }
 }
开发者ID:damnpoet,项目名称:yiicart,代码行数:23,代码来源:AttributeForm.php


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