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


PHP Tag::save方法代码示例

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


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

示例1: 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

示例2: setTags

 public static function setTags($entryId, $tags)
 {
     if (!$tags) {
         return;
     }
     // Write new tags to Tag table
     try {
         foreach ($tags as $k => $t) {
             // Add new tag if id is not exist
             if (!isset($t['id'])) {
                 $tag = new Tag();
                 $tag->text = $t['text'];
                 $tag->save();
                 $tags[$k]['id'] = $tag->id;
             }
         }
     } catch (Exception $e) {
         return $e->getMessage();
     }
     // Update tags for current entry
     //TODO: rewrite with junction table relations
     try {
         EntryTag::deleteAll(['entry_id' => (int) $entryId]);
         foreach ($tags as $t) {
             $e = new EntryTag();
             $e->tag_id = $t['id'];
             $e->entry_id = $entryId;
             $e->save();
         }
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:Atre,项目名称:uran_test,代码行数:33,代码来源:EntryTag.php

示例3: store

 public function store(Request $request)
 {
     $tag = new Tag();
     $tag->fill($request->all());
     $tag->save();
     return $tag;
 }
开发者ID:Wade-Nairn,项目名称:nibblr-WE06,代码行数:7,代码来源:TagController.php

示例4: 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

示例5: actionCreate

 /**
  * Страница добавления метки.
  *
  * @return string|\yii\web\Response
  */
 public function actionCreate()
 {
     $modelTag = new Tag();
     if ($modelTag->load(Yii::$app->request->post()) && $modelTag->save()) {
         return $this->redirect(['back-tag/view', 'id' => $modelTag->id]);
     }
     return $this->render('/back/tag/create', ['modelTag' => $modelTag]);
 }
开发者ID:Rey8d01,项目名称:book-catalog,代码行数:13,代码来源:BackTagController.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Seeds the tag table
     foreach (range(1, 1000) as $t) {
         $tag = new Tag();
         $tag->tag_name = str_shuffle('abcdefghijklmnopqrstuvwxyz');
         $tag->save();
     }
 }
开发者ID:RichNwankwo,项目名称:Gladysrepo,代码行数:14,代码来源:TagSeeder.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $tag = new Tag();
     foreach (array_keys($this->fields) as $field) {
         $tag->{$field} = $request->get($field);
     }
     $tag->save();
     return redirect('/admin/tag')->withSuccess("The tag '{$tag->tag}' was created.");
 }
开发者ID:kientrunghuynh,项目名称:elsa-blog,代码行数:15,代码来源:TagController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $tag = new Tag();
     $tag->tagname = $request->get('tagname');
     $saveStatus = $tag->save();
     if (!$saveStatus) {
         abort(500, 'Some error occurred while saving tag data');
     }
 }
开发者ID:shubhamarora,项目名称:laravel-playground,代码行数:15,代码来源:TagsController.php

示例9: actionCreate

 /**
  * Creates a new Tag model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Tag();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->tag_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:vab777,项目名称:marts.id_be,代码行数:14,代码来源:TagController.php

示例10: createItem

 public function createItem($item)
 {
     $tag = new Tag();
     $tag->name = $item['name'];
     $tag->parent_id = $item['parent_id'];
     $tag->created = date('Y-m-d H:i:s');
     $tag->updated = date('Y-m-d H:i:s');
     $tag->save();
 }
开发者ID:kacana,项目名称:admin,代码行数:9,代码来源:Tag.php

示例11: saved

 public function saved($model)
 {
     foreach ($model->tags as $tag) {
         $new_tag = Tag::where('type', '=', $tag->type)->where('tag', '=', $tag->tag)->first();
         if (!$new_tag) {
             $new_tag = new Tag(['type' => $tag->type, 'tag' => $tag->tag]);
             $new_tag->save();
         }
     }
 }
开发者ID:erickmo,项目名称:CapcusAPI,代码行数:10,代码来源:EmbedTagsObserver.php

示例12: create

 /**
  * Create tag
  *
  * @param Request $request
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function create(Request $request)
 {
     if ($request->isMethod('post')) {
         $rules = ['name' => 'required|unique:tags,name'];
         Validator::make($request->all(), $rules)->validate();
         $tag = new Tag();
         $tag->name = $request->input('name');
         $tag->save();
         return redirect()->route('tags');
     } else {
         return view('admin.tag.create');
     }
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:19,代码来源:TagController.php

示例13: addTags

 public function addTags($tags = [])
 {
     $rowTagsName = Tag::all(['name'])->toArray();
     $rowTagsName = array_flatten($rowTagsName);
     foreach ($tags as $key => $tag) {
         if (in_array($tag, $rowTagsName)) {
         } else {
             $tag = new Tag();
             $tag->name = $tag;
             $tag->save();
         }
     }
 }
开发者ID:limahfud,项目名称:skripsi,代码行数:13,代码来源:Product.php

示例14: actionCreate

 /**
  * Creates a new Tag model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Tag();
     if ($model->load(Yii::$app->request->post())) {
         if ($result = $model->save()) {
             $model->setActive();
             return $this->message('标签创建成功', 'success', ['view', 'id' => $model->id]);
         }
         return $this->message(array_values($model->getFirstErrors())[0], 'error');
     } else {
         //            return $this->render('create', [
         //                'model' => $model,
         //            ]);
     }
 }
开发者ID:hackvijay,项目名称:yii-qa,代码行数:20,代码来源:TagController.php

示例15: addTags

 public function addTags($tags)
 {
     foreach ($tags as $name) {
         $aTag = Tag::find()->where(['name' => $name])->one();
         $aTagCount = Tag::find()->where(['name' => $name])->count();
         if (!$aTagCount) {
             $tag = new Tag();
             $tag->name = $name;
             $tag->frequency = 1;
             $tag->save();
         } else {
             $aTag->frequency += 1;
             $aTag->save();
         }
     }
 }
开发者ID:tvdrupal,项目名称:yii2_blog_weixistyle,代码行数:16,代码来源:Tag.php


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