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


PHP Option::find方法代码示例

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


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

示例1: getOptions

 /**
  * 获取网站配置数组
  * @return array
  */
 public static function getOptions()
 {
     if (self::$_options == null) {
         $options = \common\models\Option::find()->asArray()->all();
         self::$_options = yii\helpers\ArrayHelper::map($options, 'name', 'value');
     }
     return self::$_options;
 }
开发者ID:Penton,项目名称:MoBlog,代码行数:12,代码来源:Option.php

示例2: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = OptionModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'value', $this->value])->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'group', $this->group]);
     return $dataProvider;
 }
开发者ID:writesdown,项目名称:app-cms,代码行数:18,代码来源:Option.php

示例3: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = OptionModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'option_name', $this->option_name])->andFilterWhere(['like', 'option_value', $this->option_value])->andFilterWhere(['like', 'option_label', $this->option_label])->andFilterWhere(['like', 'option_group', $this->option_group]);
     return $dataProvider;
 }
开发者ID:tampaphp,项目名称:app-cms,代码行数:21,代码来源:Option.php

示例4: getAll

 /**
  * @param null $template_id
  * @return array
  */
 public static function getAll($template_id = null)
 {
     $options = [];
     if ($template_id) {
         $model = Option::find()->where(['template_id' => $template_id])->all();
     } else {
         $model = Option::find()->all();
     }
     if ($model) {
         foreach ($model as $m) {
             $options[$m->id] = $m->name;
         }
     }
     return $options;
 }
开发者ID:darkffh,项目名称:yii2-lowbase,代码行数:19,代码来源:Option.php

示例5: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $this->scenario = 'search';
     $query = Option::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'template_id' => $this->template_id, 'multiple' => $this->multiple, 'require' => $this->require, 'type' => $this->type]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
开发者ID:darkffh,项目名称:yii2-lowbase,代码行数:22,代码来源:OptionSearch.php

示例6: getOptions

 /**
  * @return array|\yii\db\ActiveRecord[]
  */
 public function getOptions()
 {
     $options = Option::find()->where(['template_id' => $this->template_id])->orderBy('id')->all();
     return $options;
 }
开发者ID:p0vidl0,项目名称:yii2-lowbase,代码行数:8,代码来源:Document.php

示例7: findModelByGroup

 /**
  * Finds the Option models based on their group.
  * If the models are not found, a 404 HTTP exception will be thrown.
  *
  * @param string $id
  *
  * @return Option the loaded model
  * @throws NotFoundHttpException if the models cannot be found
  */
 protected function findModelByGroup($id)
 {
     if ($model = Option::find()->where(['option_group' => $id])->indexBy('option_name')->all()) {
         return $model;
     }
     throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.'));
 }
开发者ID:tampaphp,项目名称:app-cms,代码行数:16,代码来源:SettingController.php

示例8: actionGroup

 /**
  * Render option page for specific group of option.
  * It will use group file if exist.
  *
  * @param string $id group name
  *
  * @return string|\yii\web\Response
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionGroup($id)
 {
     $model = Option::find()->where(['option_group' => $id])->indexBy('option_name')->all();
     if ($options = Yii::$app->request->post('Option')) {
         foreach ($options as $option_name => $option) {
             Option::up($option_name, $option['option_value']);
         }
         Yii::$app->getSession()->setFlash('success', Yii::t('writesdown', 'Settings successfully saved.'));
         return $this->redirect(['group', 'id' => $id]);
     }
     if ($model) {
         if (is_file($viewFile = $this->getViewPath() . '/' . strtolower($id) . '.php')) {
             return $this->render(strtolower($id), ['model' => (object) $model, 'group' => $id]);
         } else {
             return $this->redirect(['index']);
         }
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:ochiem,项目名称:app-cms,代码行数:29,代码来源:SettingController.php


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