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


PHP Tag::find方法代码示例

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


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

示例1: getById

 /**
  * Get tag by id.
  *
  * @param $id
  * @return mixed
  */
 public function getById($id)
 {
     $tag = $this->model->find($id);
     if (!is_null($tag)) {
         $tag->hot++;
         $tag->update();
     }
     return $tag;
 }
开发者ID:forehalo,项目名称:materialize-blog,代码行数:15,代码来源:TagRepository.php

示例2: actionInit

 public function actionInit()
 {
     $imageList = Image::find()->asArray()->all();
     foreach ($imageList as $image) {
         $rawFilePath = $image['rawFilePath'];
         $match = [];
         if (preg_match('/\\/homeNASDownloads\\/photo_[0-9\\-]+\\/?(.*)/', dirname($rawFilePath), $match)) {
             $tagName = $match[1];
             if (empty($tagName)) {
                 continue;
             }
             $tag = Tag::find()->where(['tagName' => $tagName])->one();
             if ($tag === null) {
                 $tag = new Tag();
                 $tag->tagName = $tagName;
                 $tag->isDelete = false;
                 $now = date('Y-m-d H:i:s');
                 $tag->createTime = $now;
                 $tag->updateTime = $now;
                 $tag->save();
             }
             $imageTag = ImageTag::find()->where(['imageId' => $image['id'], 'tagId' => $tag->id])->one();
             if ($imageTag == null) {
                 $imageTag = new ImageTag();
                 $imageTag->imageId = $image['id'];
                 $imageTag->tagId = $tag->id;
                 $imageTag->isDelete = false;
                 $imageTag->createTime = $now;
                 $imageTag->updateTime = $now;
                 $imageTag->save();
             }
         }
     }
 }
开发者ID:tomjamescn,项目名称:photo_gallery,代码行数:34,代码来源:ImageTagController.php

示例3: addTags

 public static function addTags($tags_str, $id)
 {
     $tags = self::string2array($tags_str);
     foreach ($tags as $one) {
         $tag_exists = Tag::find()->where("name = '" . $one . "'")->one();
         //var_dump($tag_exists); exit;
         if ($tag_exists == null) {
             $tag = new Tag();
             $tag->name = $one;
             $tag->frequency = 1;
             $tag->items .= $id;
             $tag->save();
         } else {
             if (array_search($id, self::string2array($tag_exists->items)) === false || array_search($id, self::string2array($tag_exists->items)) < 0) {
                 //var_dump($id);
                 //var_dump(self::string2array($tag_exists->items));
                 //var_dump(array_search($id, self::string2array($tag_exists->items)) === false);
                 //var_dump(array_search($id, self::string2array($tag_exists->items)) < 0); exit;
                 $tag_exists->frequency++;
                 $tag_exists->items .= "," . $id;
                 $tag_exists->update();
             }
         }
     }
 }
开发者ID:roman1970,项目名称:lis,代码行数:25,代码来源:Tag.php

示例4: delete

 public function delete()
 {
     $user = $this->auth();
     $tag = Tag::find(Input::get('tagId'));
     $tag->delete();
     return $this->output(new \stdClass());
 }
开发者ID:guodong,项目名称:wish-api,代码行数:7,代码来源:TagController.php

示例5: actionIndex

 /**
  * Lists all Partner models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new PartnerSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     // $this->ajaxAssign('tags', Tag::find()->asArray()->publicTags()->all());
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'tags' => [__('Public tags') => Tag::find()->publicTags()->all(), __('Personal tags') => Tag::find()->personalTags()->all()]]);
 }
开发者ID:vsguts,项目名称:crm,代码行数:11,代码来源:PartnerController.php

示例6: getTagWeights

 public static function getTagWeights($limit = 20)
 {
     $models = Tag::find()->with('posts')->orderBy('name')->all();
     $minFrequency = 0;
     $maxFrequency = 0;
     foreach ($models as $model) {
         $weight = count($model->posts);
         $minFrequency = $minFrequency > $weight ? $weight : $minFrequency;
         $maxFrequency = $maxFrequency < $weight ? $weight : $maxFrequency;
     }
     $sizeRange = self::MAX_FONT_SIZE - self::MIN_FONT_SIZE;
     $minCount = log($minFrequency + 1);
     $maxCount = log($maxFrequency + 1);
     if ($maxCount != $minCount) {
         $countRange = $maxCount - $minCount;
     } else {
         $countRange = 1;
     }
     $tags = [];
     foreach ($models as $model) {
         $tags[$model->name] = round(self::MIN_FONT_SIZE + (log(count($model->posts) + 1) - $minCount) * ($sizeRange / $countRange));
     }
     arsort($tags);
     return $tags;
 }
开发者ID:mamontovdmitriy,项目名称:aaaaa,代码行数:25,代码来源:Tag.php

示例7: actionCreate

 /**
  * Creates a new Artist model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Artist();
     $photos = [];
     if (Yii::$app->request->isPost) {
         for ($i = 0; $i < count(Yii::$app->request->post('Photo', [])); $i++) {
             $photos[] = new Photo();
         }
         $data = Yii::$app->request->post();
         $data['Artist']['user_id'] = Yii::$app->user->id;
     } else {
         $data = null;
     }
     if ($model->load($data) && $model->save()) {
         Photo::loadMultiple($photos, Yii::$app->request->post());
         foreach ($photos as $photo) {
             $photo->artist_id = $model->id;
         }
         if (Photo::validateMultiple($photos)) {
             foreach ($photos as $photo) {
                 $model->link('photos', $photo);
             }
         }
         $tags = Yii::$app->request->post('Artist', '');
         $tags = Tag::find()->where(['in', 'id', explode(',', $tags['tags'])])->all();
         foreach ($tags as $tag) {
             $model->link('tags', $tag);
         }
         return $this->redirect(['release/index', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'photos' => $photos]);
     }
 }
开发者ID:shkrad,项目名称:my_music_storage,代码行数:38,代码来源:ArtistController.php

示例8: show

 /**
  * Get a tag JSON by a given tag_id
  * method: get
  * route: api/tags/<tag_id>
  * @param  int $tag_id
  * @return json {"success": true or false, "data": {"tag": tag}};
  */
 public function show($tag_id)
 {
     $tag = Tag::find($tag_id);
     if ($tag == NULL) {
         return \Response::json(array("success" => false));
     }
     return \Response::json(["success" => true, "data" => array("tag" => $tag)]);
 }
开发者ID:nekonekonik,项目名称:nuswhispers,代码行数:15,代码来源:TagsController.php

示例9: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $tag = Tag::find($id);
     if (empty($tag)) {
         Flash::error('Tag not found');
         return redirect(route('admin.tags.index'));
     }
     return view('admin.tags.show')->with('tag', $tag);
 }
开发者ID:jclyons52,项目名称:mycourse-rocks,代码行数:15,代码来源:TagController.php

示例10: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $tag = Tag::find($id);
     if (!$tag) {
         return $this->respondNotFound();
     }
     return $this->respond(['data' => [$this->tagTransformer->transform($tag->toArray())]]);
 }
开发者ID:RichNwankwo,项目名称:Gladysrepo,代码行数:15,代码来源:TagController.php

示例11: deleteChildRe

 public function deleteChildRe($id)
 {
     $tags = $this->where('parent_id', $id)->get();
     if (count($tags) > 0) {
         foreach ($tags as $tag) {
             Tag::find($tag->id)->delete();
         }
     }
 }
开发者ID:kacana,项目名称:admin,代码行数:9,代码来源:Tag.php

示例12: delete

 public function delete($id)
 {
     $tag = Tag::find($id);
     if (!$tag) {
         return false;
     }
     $tag->posts()->detach();
     return $tag->delete();
 }
开发者ID:go-labs,项目名称:php_rest_poc,代码行数:9,代码来源:EloquentTagRepository.php

示例13: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $tag = Tag::find($id);
     $tag->tagname = $request->get('tagname');
     $updateStatus = $tag->save();
     if (!$updateStatus) {
         abort(500, 'Some error occurred while saving user data');
     }
 }
开发者ID:shubhamarora,项目名称:laravel-playground,代码行数:16,代码来源:TagsController.php

示例14: run

 public function run()
 {
     $tags = Tag::find()->joinWith(['postLinks'])->groupBy('tag.id')->limit($this->count)->orderBy('tag.frequency desc')->all();
     $output = '';
     foreach ($tags as $tag) {
         /* @var $tag Tag */
         $output .= Html::a('#' . $tag->tag, ['/frontend/post/search', 'tag' => $tag->tag], ['class' => 'tag']);
     }
     return $output;
 }
开发者ID:hauntd,项目名称:help-center,代码行数:10,代码来源:TagsWidget.php

示例15: publish

 /**
  * Update status of the specified resource in storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function publish($id, $status = 'n')
 {
     if (!is_admin()) {
         return abort(404);
     }
     $tag = Tag::find($id);
     $status = $status == 'y' ? Tag::openCode : Tag::hiddenCode;
     TagService::updateTag($tag->id, $status);
     return redirect()->back()->with('success', '[' . $tag->name . ']을 공개했습니다.');
 }
开发者ID:joonas-yoon,项目名称:acm-oj,代码行数:16,代码来源:TagsController.php


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