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


PHP Tag::findOne方法代码示例

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


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

示例1: findModel

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

示例2: actionDelete

 /**
  * Удаление метки.
  *
  * @param int $id
  * @return \yii\web\Response
  */
 public function actionDelete($id)
 {
     /** @var Tag $modelTag */
     $modelTag = Tag::findOne($id);
     if ($modelTag->delete()) {
         return $this->redirect(['back-tag/index']);
     }
     return $this->refresh();
 }
开发者ID:Rey8d01,项目名称:book-catalog,代码行数:15,代码来源:BackTagController.php

示例3: actionCreate

 /**
  * Creates a new TagUserAccess model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($tagID)
 {
     $model = new TagUserAccess();
     /** @var Tag $tag */
     $tag = Tag::findOne($tagID);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index', 'tagID' => $tagID]);
     } else {
         return $this->render('create', ['model' => $model, 'tag' => $tag, 'users' => $this->getAvailableUsers($tagID)]);
     }
 }
开发者ID:app-dev-ru,项目名称:lingnote,代码行数:16,代码来源:TagUserAccessController.php

示例4: actionGetentry

 public function actionGetentry()
 {
     $id = Yii::$app->request->get('id');
     $tags = EntryTag::findAll(['entry_id' => $id]);
     $retTags = [];
     // TODO relations
     foreach ($tags as $k => $v) {
         $retTags[] = Tag::findOne($v['tag_id']);
     }
     Yii::$app->response->format = Response::FORMAT_JSON;
     return (object) ['data' => Entry::findOne($id), 'tags' => $retTags];
 }
开发者ID:Atre,项目名称:uran_test,代码行数:12,代码来源:SiteController.php

示例5: _saveBook

 /**
  * Сохраняет модель и связанные данные
  *
  * @param Book $modelBook
  * @return \yii\web\Response
  */
 private function _saveBook(Book $modelBook)
 {
     $authorIds = Yii::$app->request->post('authors');
     $tagIds = Yii::$app->request->post('tags');
     if ($modelBook->load(Yii::$app->request->post()) && $modelBook->save()) {
         array_map(function ($model) use($modelBook) {
             $modelBook->unlink('authors', $model, true);
         }, $modelBook->authors);
         foreach ($authorIds ?: [] as $authorId) {
             /** @var Author $modelAuthor */
             $modelAuthor = Author::findOne($authorId);
             $modelBook->link('authors', $modelAuthor);
         }
         array_map(function ($model) use($modelBook) {
             $modelBook->unlink('tags', $model, true);
         }, $modelBook->tags);
         foreach ($tagIds ?: [] as $tagId) {
             /** @var Tag $modelTag */
             $modelTag = Tag::findOne($tagId);
             $modelBook->link('tags', $modelTag);
         }
         return $this->redirect(['back-book/view', 'id' => $modelBook->id]);
     }
 }
开发者ID:Rey8d01,项目名称:book-catalog,代码行数:30,代码来源:BackBookController.php

示例6: actionArtist

 public function actionArtist()
 {
     $model = Artist::findOne(Yii::$app->request->post('pk', ''));
     $ownerId = $model->user_id;
     if (Yii::$app->request->post('name', '') == 'artist-tags') {
         $artistTags = (new \yii\db\Query())->select('tag_id')->from('artist_tag')->where(['artist_id' => $model->id])->column();
         $requestTags = Yii::$app->request->post('value', []);
         foreach ($requestTags as $tagId) {
             if (!in_array($tagId, $artistTags)) {
                 $tag = Tag::findOne($tagId);
                 if ($tag) {
                     $model->link('tags', $tag);
                 }
             }
         }
         foreach ($artistTags as $tagId) {
             if (!in_array($tagId, $requestTags)) {
                 Yii::$app->db->createCommand()->delete('artist_tag', ['artist_id' => $model->id, 'tag_id' => $tagId])->execute();
             }
         }
         return null;
     }
     return self::update($model, $ownerId);
 }
开发者ID:shkrad,项目名称:my_music_storage,代码行数:24,代码来源:UpdateController.php

示例7: actionSaveantrag

 /**
  * @param int $antrag_id
  *
  * @return string
  */
 public function actionSaveantrag($antrag_id)
 {
     \yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
     \yii::$app->response->headers->add('Content-Type', 'application/json');
     /** @var Antrag $antrag */
     $antrag = Antrag::findOne($antrag_id);
     if (!$antrag) {
         return json_encode(['error' => 'Antrag nicht gefunden.']);
     }
     $antrag->notiz = $_POST['antrag']['notiz'];
     if ($_POST['antrag']['abgeschlossen'] == 1) {
         $antrag->status_override = $antrag->status == 'erledigt' ? '' : 'erledigt';
     } else {
         $antrag->status_override = $antrag->status == 'erledigt' ? 'In Bearbeitung' : '';
     }
     if (!$antrag->save()) {
         return json_encode(['error' => 'Es ist ein (seltsamer) Fehler beim Speichern aufgetreten.']);
     }
     foreach ($antrag->tags as $tag) {
         $antrag->unlink('tags', $tag, true);
     }
     $tags = explode(',', $_POST['antrag']['tags']);
     foreach ($tags as $tagName) {
         $tag = Tag::findOne(['name' => $tagName]);
         if (!$tag) {
             $tag = new Tag();
             $tag->name = $tagName;
             $tag->save();
         }
         $antrag->link('tags', $tag);
     }
     $row = $this->renderPartial('index_antrag_row', ['antrag' => $antrag]);
     return json_encode(['success' => 1, 'content' => $row]);
 }
开发者ID:CatoTH,项目名称:Stadtratsantraege,代码行数:39,代码来源:SiteController.php

示例8: findByName

 public static function findByName($name)
 {
     return Tag::findOne(['name' => $name, 'user_id' => Yii::$app->user->id]);
 }
开发者ID:app-dev-ru,项目名称:lingnote,代码行数:4,代码来源:Tag.php

示例9: getTegName

 protected function getTegName($id)
 {
     if (($tag = Tag::findOne($id)) !== null) {
         return $tag->tag_name;
     } else {
         throw new NotFoundHttpException('The requested page does not exist. (getTegName())');
     }
 }
开发者ID:KosovMax,项目名称:mysite,代码行数:8,代码来源:DescriptionController.php

示例10: findModel

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

示例11: function

use yii\helpers\Html;
$this->title = \Yii::t('app', 'Wiki') . ' - ' . $project->title . ' - ' . $this->params['appSettings']['app_name'];
echo $this->render('/project/_topMenu', ['model' => $project]);
?>

<div class="row">
    <div class="col-sm-10">
        <?php 
echo Html::a('<i class="fa fa-plus"></i> ' . \Yii::t('app', 'Add'), ['/wiki/create', 'id' => $project->id], ['class' => 'btn btn-primary pull-right']);
?>
        <h1>
            <?php 
echo \Yii::t('app', 'Wiki');
if (isset($tagId)) {
    echo ' / <i>' . \app\models\Tag::findOne($tagId)->name . '</i>';
}
?>
        </h1>

        <?php 
echo \yii\grid\GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'layout' => '{items} {pager}', 'columns' => [['attribute' => 'title', 'format' => 'raw', 'value' => function ($data) {
    return Html::a($data->title, ['/wiki/view', 'id' => $data->id]);
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
?>
    </div>
    <div class="col-sm-2">
        <?php 
echo \app\components\widgets\TagsPanelWidget::widget(['modelName' => \app\models\TagModel::MODEL_WIKI, 'projectId' => $project->id]);
?>
    </div>
开发者ID:mops1k,项目名称:yiimine,代码行数:30,代码来源:index.php

示例12: foreach

    // анализ и вывод соответствующего объекта: картинка, галлерея, файл, музыка, видео, гиперссылка
    echo ContentGenerator::parse($data);
} else {
    echo str_replace("\n", "<br>", $model->text);
    /*Html::encode()*/
    // plain text, not json
}
?>
        <?php 
if (!empty($model->tags)) {
    ?>
            <br>--
            <br>
            <?php 
    foreach ($model->tags as $tag) {
        $tagName = Tag::findOne($tag)->name;
        echo Html::a("#" . $tagName, Url::toRoute(['/', 'query' => "#" . $tagName])) . " ";
    }
    ?>
        <?php 
}
?>
        <hr>
        <?php 
$form = ActiveForm::begin(['action' => '', 'method' => 'post', 'id' => 'edit-form']);
echo Html::tag("div", $form->field($model, 'id')->hiddenInput() . $form->field($model, 'hash')->hiddenInput() . $form->field($model, 'created')->hiddenInput() . $form->field($model, 'ip')->hiddenInput() . $form->field($model, 'user_agent')->hiddenInput(), ['style' => "display: none;"]);
echo $form->field($model, 'text')->textarea();
echo $form->field($model, 'tags')->widget(Select2::className(), ['data' => ArrayHelper::map(Tag::find()->all(), 'id', 'name'), 'options' => ['multiple' => true, 'placeholder' => 'Теги'], 'pluginOptions' => ['tags' => true, 'maximumInputLength' => 255]]);
echo Html::tag("div", Html::submitButton('Опубликовать', ['class' => 'btn btn-success']), ['style' => "text-align: center;"]);
$form->end();
?>
开发者ID:mamontovdmitriy,项目名称:aaaaa,代码行数:31,代码来源:_edit.php

示例13: strlen

<div  class="description-index">
	<div class="tab">
		<div class="tab-cell">
			<h1>Стаття</h1>
		</div>
		<div class="tab-cell">
			<?php 
echo Html::a('Створити статті', ['create'], ['class' => 'btn btn-success']);
?>
		</div>
	</div>

	<?php 
foreach ($model as $m) {
    $tag = Tag::findOne($m->tag);
    $tag = $tag->tag_name;
    $desc = null;
    $to_sub = 500;
    $size = strlen($m->art_body);
    if ($size <= $to_sub) {
        $desc = $m->art_body;
    } else {
        $desc = mb_substr($m->art_body, 0, $to_sub) . "... <a href='/mysite/basic/web/index.php?r=description/read&id={$m->desid}'> Читать далі>></a>";
    }
    echo "<div style='display:table;width:100%'>\n\t\t\t\t\t<div style='display:table-cell;'>\n\t\t\t\t\t\t<h3><a href='/mysite/basic/web/index.php?r=description/read&id={$m->desid}'>{$m->header}</a></h3>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div style='display:table-cell;text-align:right;'>\n\t\t\t\t\t\t<a href='/mysite/basic/web/index.php?r=description/update&id={$m->desid}' ><i class='fa fa-pencil' title='Редагувати'></i></a>\n\t\t\t\t\t\t<a data-confirm='Are you sure you want to delete this item?' data-method='post' href='/mysite/basic/web/index.php?r=description/delete&id={$m->desid}' ><i class='fa fa-times' title='Видалити' ></i></a>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div>\n\t\t\t\t\t{$desc}\n\t\t\t\t</div>\n\t\t\t\t<div>\n\t\t\t\t\t<span style='color:rgb(246, 131, 2);'>Теги: #{$tag}</span>\n\t\t\t\t\t<span style='float: right;color: gray;'>Oпубліковано: {$m->date}</span>\n\t\t\t\t</div>\n\t\t\t\t<hr />\n\t\t\t";
}
?>
	
</div>
开发者ID:KosovMax,项目名称:mysite,代码行数:29,代码来源:index.php

示例14:

<?php

use yii\helpers\Html;
use yii\grid\GridView;
use app\models\Tag;
/* @var $this yii\web\View */
/* @var $searchModel app\models\DescriptionSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Заголовок: ' . $model->header;
$this->params['breadcrumbs'][] = ['label' => 'Стаття', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$html_photo = '';
if ($model->photo != '') {
    $html_photo = "<div><img src='{$model->photo}' width='300' /></div>";
}
$tag = Tag::findOne($model->tag);
?>

<div>
	<div class="tab2">
		<div class="tab2-cell">
			<h3><?php 
echo $model->header;
?>
</h3>
		</div>
		<div  class="tab2-cell" style='text-align:right;'>
			<span style='float: right;color: gray;'>Oпубліковано: <?php 
echo $model->date;
?>
</span>
开发者ID:KosovMax,项目名称:mysite,代码行数:31,代码来源:read.php


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