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


PHP Group::findOne方法代码示例

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


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

示例1: findModel

 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Group::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:hoangngk,项目名称:adminpanel,代码行数:15,代码来源:GroupsController.php

示例2: showGallery

 public function showGallery()
 {
     $app = Yii::$app;
     $groups = Group::getRoots();
     $products = [];
     if (!empty($groups)) {
         $default_group = $groups[0]->id;
         $group = $app->request->getQueryParam('group', $default_group);
         $products = Group::findOne($group)->linkedProducts;
     }
     return $this->renderPartial('_gallery', ['groups' => (array) $groups, 'products' => (array) $products]);
 }
开发者ID:secondsano,项目名称:mebel,代码行数:12,代码来源:SiteController.php

示例3: processCode

 public function processCode($fullCode)
 {
     $code = $fullCode['code'];
     $original = $fullCode['original'];
     if ($this->isCodeActive($code)) {
         $group = Group::findOne($code->z_p_id)->toArray();
         $bank = Bank::findOne($code->z_b_id)->toArray();
         $form = Form::findOne(['f_klasse' => $bank['klasse'], 'f_p_id' => $group['p_id']]);
         $style = Style::findOne(['s_b_id' => $bank['b_id'], 's_p_id' => $group['p_id']]);
         if (!$style) {
             $style = Settings::getSetting('style');
         } else {
             $style = $style->style;
         }
         $label = Yii::$app->params['default_next_label'];
         $message = Yii::$app->params['default_next_message'];
         if ($this->language != "default") {
             $language = Language::findOne($this->language);
             if ($language != null) {
                 if ($language->label != '') {
                     $label = $language->label;
                 }
                 if ($language->message != '') {
                     $message = $language->message;
                 }
             }
         }
         Yii::$app->session['anketData'] = ['original' => $original, 'code' => $code->toArray(), 'group' => $group, 'bank' => $bank, 'form' => $form->f_id, 'status' => 0, 'lang' => $this->language, 'style' => $style, 'label' => $label, 'message' => $message];
         $meta = Meta::findOne(['m_z_id' => $code->z_id]);
         if (!$meta) {
             $meta = new Meta();
             $meta->m_z_id = $code->z_id;
             $meta->ip = $_SERVER['REMOTE_ADDR'];
             $meta->time_start = time();
         } else {
             $meta->ip = $_SERVER['REMOTE_ADDR'];
         }
         $meta->save();
         return true;
     }
     return false;
 }
开发者ID:emotionbanker,项目名称:emotion-banking,代码行数:42,代码来源:AnketForm.php

示例4: processCode

 public function processCode($code)
 {
     if ($this->isCodeActive($code)) {
         $group = Group::findOne($code->z_p_id)->toArray();
         $bank = Bank::findOne($code->z_b_id)->toArray();
         $form = Form::findOne(['f_klasse' => $bank['klasse'], 'f_p_id' => $group['p_id']]);
         Yii::$app->session['anketData'] = ['code' => $code->toArray(), 'group' => $group, 'bank' => $bank, 'form' => $form->f_id, 'status' => 0, 'lang' => $this->language];
         $meta = Meta::findOne(['m_z_id' => $code->z_id]);
         if (!$meta) {
             $meta = new Meta();
             $meta->m_z_id = $code->z_id;
             $meta->ip = $_SERVER['REMOTE_ADDR'];
             $meta->time_start = time();
         } else {
             $meta->ip = $_SERVER['REMOTE_ADDR'];
         }
         $meta->save();
         return true;
     }
     return false;
 }
开发者ID:emotionbanker,项目名称:emotionbanking,代码行数:21,代码来源:AnketForm.php

示例5: actionEditRelation

 /**
  * 项目审核管理员设置
  *
  * @return string
  * @throws \Exception
  */
 public function actionEditRelation($id, $type = 0)
 {
     $group = Group::findOne($id);
     if (!$group) {
         throw new \Exception('关系不存在:)');
     }
     $project = Project::findOne($group->project_id);
     if ($project->user_id != $this->uid) {
         throw new \Exception('不可以操作其它人的项目:)');
     }
     if (!in_array($type, [Group::TYPE_ADMIN, Group::TYPE_USER])) {
         throw new \Exception('未知的关系类型:)');
     }
     $group->type = (int) $type;
     if (!$group->save()) {
         throw new \Exception('更新失败');
     }
     $this->renderJson([]);
 }
开发者ID:richardfan,项目名称:walle-web,代码行数:25,代码来源:ConfController.php

示例6: actionEditRelation

 /**
  * 项目审核管理员设置
  *
  * @return string
  * @throws \Exception
  */
 public function actionEditRelation($id, $type = 0)
 {
     $group = Group::findOne($id);
     if (!$group) {
         throw new \Exception(yii::t('conf', 'relation not exists'));
     }
     $project = Project::findOne($group->project_id);
     if ($project->user_id != $this->uid) {
         throw new \Exception(yii::t('w', 'you are not master of project'));
     }
     if (!in_array($type, [Group::TYPE_ADMIN, Group::TYPE_USER])) {
         throw new \Exception(yii::t('conf', 'unknown relation type'));
     }
     $group->type = (int) $type;
     if (!$group->save()) {
         throw new \Exception(yii::t('w', 'update failed'));
     }
     $this->renderJson([]);
 }
开发者ID:charlestang,项目名称:walle-web,代码行数:25,代码来源:ConfController.php

示例7: function

$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-text-index">

    <p>
        <?php 
echo Html::a('Neuer Benutzertext', ['user-text/create/' . $type], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'ut_id', ['attribute' => 'p_id', 'filterType' => GridView::FILTER_SELECT2, 'filter' => InputHelper::getDropdownOptions('app\\models\\Group', 'p_id', 'bezeichnung', true, true), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'value' => function ($model, $key, $index, $widget) {
    if (!$model->p_id) {
        return 'Alle';
    }
    $group = \app\models\Group::findOne($model->p_id);
    return $group ? $group->bezeichnung : $model->p_id;
}, 'filterInputOptions' => ['placeholder' => 'Bitte wählen Sie'], 'format' => 'raw'], ['attribute' => 'b_id', 'filterType' => GridView::FILTER_SELECT2, 'filter' => InputHelper::getDropdownOptions('app\\models\\Bank', 'b_id', 'bezeichnung', true, true), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'value' => function ($model, $key, $index, $widget) {
    if (!$model->b_id) {
        return 'Alle';
    }
    $group = \app\models\Bank::findOne($model->b_id);
    return $group ? $group->bezeichnung : $model->b_id;
}, 'filterInputOptions' => ['placeholder' => 'Bitte wählen Sie'], 'format' => 'raw'], ['attribute' => 'l_id', 'filterType' => GridView::FILTER_SELECT2, 'filter' => InputHelper::getDropdownOptions('app\\models\\Language', 'l_id', 'name', true, true, true), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'value' => function ($model, $key, $index, $widget) {
    if (!$model->b_id) {
        return 'Default';
    }
    $group = \app\models\Language::findOne($model->l_id);
    return $group ? $group->name : $model->l_id;
}, 'filterInputOptions' => ['placeholder' => 'Bitte wählen Sie'], 'format' => 'raw'], ['attribute' => 't_id', 'value' => function ($model, $key, $index, $widget) {
    $group = \app\models\Text::findOne($model->t_id);
开发者ID:emotionbanker,项目名称:emotionbanking,代码行数:31,代码来源:index.php

示例8: actionDeleteRelation

 /**
  * 删除项目的用户关系
  *
  * @return string
  * @throws \Exception
  */
 public function actionDeleteRelation($id)
 {
     $group = Group::findOne($id);
     if (!$group) {
         throw new \Exception('关系不存在:)');
     }
     $project = Project::findOne($group->project_id);
     if ($project->user_id != $this->uid) {
         throw new \Exception('不可以操作其它人的项目:)');
     }
     if (!$group->delete()) {
         throw new \Exception('删除失败');
     }
     $this->renderJson([]);
 }
开发者ID:ZuoGuocai,项目名称:walle-web,代码行数:21,代码来源:ConfController.php

示例9: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     $oldImages = $this->imagesWithoutPlaceholder;
     $newImages = $this->pictures;
     // Detach old images
     foreach ($oldImages as $img) {
         if (!in_array($img->filePath, $newImages)) {
             $this->removeImage($img);
         } else {
             $newImages = array_diff($newImages, [$img->filePath]);
         }
     }
     // Attach new images
     foreach ($newImages as $path) {
         $this->attachImage($path);
     }
     // Set main image
     $mainImage = $this->findImageByPath($this->mainPicture);
     if ($mainImage) {
         $this->setMainImage($mainImage);
     }
     // Link and unlink groups
     $oldGroups = ArrayHelper::map($this->linkedGroups, 'id', 'id');
     $newGroups = $this->groups;
     $addGroups = array_diff($newGroups, $oldGroups);
     $removeGroups = array_diff($oldGroups, $newGroups);
     foreach ($addGroups as $gid) {
         $this->link('linkedGroups', Group::findOne($gid));
     }
     foreach ($removeGroups as $gid) {
         $this->unlink('linkedGroups', Group::findOne($gid), true);
     }
 }
开发者ID:secondsano,项目名称:mebel,代码行数:34,代码来源:Product.php


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