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


PHP Tag::find方法代码示例

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


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

示例1: test_should_bind_sql_bind_in_using_active_records

 public function test_should_bind_sql_bind_in_using_active_records()
 {
     $Tag = new Tag();
     $Tag->create(array('name' => 'Tag 1'));
     $Tag->create(array('name' => 'Tag 2'));
     $this->assertTrue($Tags = $Tag->find(array('conditions' => array('name IN (?)', $Tag->find()))));
     $this->assertEqual($Tags[0]->name, 'Tag 1');
     $this->assertEqual($Tags[1]->name, 'Tag 2');
 }
开发者ID:joeymetal,项目名称:v1,代码行数:9,代码来源:_AkActiveRecord_finders.php

示例2: set_tags

 /**
  * set and add new tags to the post entity
  * @param string $val
  * @return array
  */
 public function set_tags($val)
 {
     if (!empty($val)) {
         $tagsArr = \Base::instance()->split($val);
         $tag_res = new Tag();
         $tags = array();
         // find IDs of known Tags
         $known_tags = $tag_res->find(array('title IN ?', $tagsArr));
         if ($known_tags) {
             foreach ($known_tags as $tag) {
                 $tags[$tag->_id] = $tag->title;
             }
             $newTags = array_diff($tagsArr, array_values($tags));
         } else {
             $newTags = $tagsArr;
         }
         // create remaining new Tags
         foreach ($newTags as $tag) {
             $tag_res->reset();
             $tag_res->title = $tag;
             $out = $tag_res->save();
             $tags[$out->_id] = $out->title;
         }
         // set array of IDs to current Post
         $val = array_keys($tags);
     }
     return $val;
 }
开发者ID:xfra35,项目名称:fabulog,代码行数:33,代码来源:post.php

示例3: add

 public static function add($id, $meta)
 {
     $desc = Description::create(['id' => $id, 'name' => $meta->name, 'market_name' => $meta->market_name ?: $meta->name, 'icon_url' => $meta->icon_url, 'icon_url_large' => isset($meta->icon_url_large) ? $meta->icon_url_large : '', 'name_color' => $meta->name_color ?: '000000']);
     if (!empty($meta->actions)) {
         foreach ($meta->actions as $idx => $action) {
             if ($action->name == 'Inspect in Game...') {
                 $desc->inspect_url_template = $action->link;
                 $desc->save();
                 break;
             }
         }
     }
     foreach ($meta->tags as $idx => $tag_data) {
         $tag = Tag::find('all', array('conditions' => array('category = ? AND category_name = ? AND internal_name = ? AND name = ?', $tag_data->category, $tag_data->category_name, $tag_data->internal_name, $tag_data->name)));
         if (empty($tag)) {
             $tag = new Tag(['category' => $tag_data->category, 'category_name' => $tag_data->category_name, 'internal_name' => $tag_data->internal_name, 'name' => $tag_data->name]);
             if (!$tag->is_valid()) {
                 $desc->delete();
                 return null;
             } else {
                 $tag->save();
             }
         } else {
             $tag = $tag[0];
         }
         if ($tag_data->category == 'Rarity') {
             $desc->name_color = $tag_data->color;
             $desc->save();
         }
         Descriptiontag::create(['description_id' => $desc->id, 'tag_id' => $tag->id]);
     }
     return $desc;
 }
开发者ID:puttyplayer,项目名称:CSGOShop,代码行数:33,代码来源:Description.php

示例4: tags

 public function tags($id)
 {
     $tag = Tag::find($id);
     $posts = $tag->posts()->get();
     $tags = Tag::with('posts')->paginate(8);
     return View::make('search', compact('posts', 'tags'));
 }
开发者ID:mkwarren21,项目名称:blog.dev,代码行数:7,代码来源:HomeController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // get POST data
     $input = Input::all();
     // set validation rules
     $rules = array('title' => 'required', 'text' => 'required', 'image' => 'required');
     // validate input
     $validation = Validator::make($input, $rules);
     // if validation fails, return the user to the form w/ validation errors
     if ($validation->fails()) {
         return Redirect::back()->withErrors($validation)->withInput();
     } else {
         // create new Post instance
         $post = Post::create(array('title' => $input['title']));
         // create Text instance w/ text body
         $text = Text::create(array('text' => $input['text']));
         // save new Text and associate w/ new post
         $post->text()->save($text);
         // create the new Image
         $image = Image::create(array('url' => $input['image']));
         // save new Text and associate w/ new post
         $post->image()->save($image);
         if (isset($input['tags'])) {
             foreach ($input['tags'] as $tagId) {
                 $tag = Tag::find($tagId);
                 $post->tags()->save($tag);
             }
         }
         // associate the post with the current user
         $post->author()->associate(Auth::user())->save();
         // redirect to newly created post page
         return Redirect::route('post.show', array($post->id));
     }
 }
开发者ID:shruti222patel,项目名称:laravel-model-demo,代码行数:39,代码来源:PostController.php

示例6: alias_name

 public function alias_name()
 {
     if ($this->alias_name === null) {
         $this->alias_name = Tag::find($this->alias_id)->name;
     }
     return $this->alias_name;
 }
开发者ID:JCQS04,项目名称:myimouto,代码行数:7,代码来源:TagAlias.php

示例7: getPostByTag

 public static function getPostByTag($tag_id)
 {
     $tagData = Tag::find($tag_id);
     if ($tagData) {
         $data = DB::select(" SELECT * FROM posts WHERE id IN (SELECT post_id FROM post_tags WHERE tag_id = {$tag_id}) ");
     }
     return $data;
 }
开发者ID:minnb,项目名称:vitduct,代码行数:8,代码来源:Template.php

示例8: dataExist

 /**
  * Verify if exist
  */
 private function dataExist($id)
 {
     $data = Tag::find($id);
     if (!$data) {
         return Redirect::route('tag_list')->with('mError', 'Ce tag est introuvable !');
     } else {
         return $data;
     }
 }
开发者ID:urashima82,项目名称:intranet,代码行数:12,代码来源:TagController.php

示例9: createPostAction

 public function createPostAction()
 {
     if ($this->request->isPost()) {
         $post = new Post();
         $post->topic = $this->request->getPost('title');
         $post->content = str_replace('</div>', '\\n', str_replace('<div>', '', $this->request->getPost('post')));
         $post->is_service = $this->request->getPost('is_service');
         $post->created_at = date('d.m.Y, h:i');
         if ($post->save()) {
             $tt = explode(',', $this->request->getPost('tags'));
             foreach ($tt as $t) {
                 $tag = Tag::findFirst(array('conditions' => 'name = ?1', 'bind' => array(1 => $t)));
                 if ($tag) {
                     $tag_post = new PostTag();
                     $tag_post->post_id = $post->id;
                     $tag_post->tag_id = $tag->id;
                     if (!$tag_post->save()) {
                         message($this, 'd', 'Ошибка привязки категории к посту');
                         return $this->response->redirect();
                     }
                 } else {
                     $tag = new Tag();
                     $tag->name = $t;
                     if ($tag->save()) {
                         $tag_post = new PostTag();
                         $tag_post->post_id = $post->id;
                         $tag_post->tag_id = $tag->id;
                         if (!$tag_post->save()) {
                             message($this, 'd', 'Ошибка привязки категории к посту');
                             return $this->response->redirect();
                         }
                     } else {
                         message($this, 'd', 'Ошибка сохранения новой категории');
                         return $this->response->redirect();
                     }
                 }
             }
             message($this, 's', 'Новость успешно добавлена');
             return $this->response->redirect();
         } else {
             foreach ($post->getMessages() as $message) {
                 message($this, "d", "Ошибка: " . $message->getMessage() . " в поле " . $message->getField() . ". Тип: " . $message->getType());
             }
             return $this->response->redirect();
         }
     } else {
         $this->assets->collection('headerJs')->addJs("js/jquery-ui.min.js");
         $this->assets->collection('headerCss')->addCss("css/jquery-ui.min.css")->addCss("css/jquery-ui.structure.min.css");
         $tt = Tag::find();
         $tags = "";
         foreach ($tt as $tag) {
             $tags .= '"' . $tag->name . '", ';
         }
         $tags = substr($tags, 0, -2);
         $this->view->setParamToView('tags', $tags);
     }
 }
开发者ID:Flerki,项目名称:CarRepairTotal,代码行数:57,代码来源:AdminController.php

示例10: destroy

 public function destroy($id)
 {
     $tag = Tag::find($id);
     $tag->delete();
     if ($tag == null) {
         return $this->statusResponse(['error' => 'No Tag found']);
     }
     return $this->statusResponse(['notice' => 'Tag deleted', 'tag' => $tag]);
 }
开发者ID:vanderlin,项目名称:halp,代码行数:9,代码来源:TagsController.php

示例11: approve

 function approve($user_id, $ip_addr)
 {
     DB::update("tag_implications SET is_pending = FALSE WHERE id = {$this->id}");
     $t = Tag::find($this->predicate_id);
     $implied_tags = implode(' ', self::with_implied(array($t->name)));
     foreach (Post::find('all', array('conditions' => array("id IN (SELECT pt.post_id FROM posts_tags pt WHERE pt.tag_id = ?)", $t->id))) as $post) {
         $post->update_attributes(array('tags' => $post->tags . " " . $implied_tags, 'updater_user_id' => $user_id, 'updater_ip_addr' => $ip_addr));
     }
 }
开发者ID:laiello,项目名称:my-imouto-booru,代码行数:9,代码来源:tag_implication.php

示例12: approve

 public function approve($user_id, $ip_addr)
 {
     self::connection()->executeSql("UPDATE tag_implications SET is_pending = FALSE WHERE id = " . $this->id);
     $t = Tag::find($this->predicate_id);
     $implied_tags = implode(' ', self::with_implied(array($t->name)));
     foreach (Post::where("id IN (SELECT pt.post_id FROM posts_tags pt WHERE pt.tag_id = ?)", $t->id)->take() as $post) {
         $post->updateAttributes(array('tags' => $post->cached_tags . " " . $implied_tags, 'updater_user_id' => $user_id, 'updater_ip_addr' => $ip_addr));
     }
 }
开发者ID:JCQS04,项目名称:myimouto,代码行数:9,代码来源:TagImplication.php

示例13: Tag

 function test_should_store_zero_strings_as_intergers()
 {
     $Tag = new Tag(array('name' => 'Ticket #21'));
     $this->assertTrue($Tag->save());
     $this->assertEqual($Tag->get('score'), 100);
     $Tag->setAttributes(array('score' => '0'));
     $this->assertTrue($Tag->save());
     $Tag =& $Tag->find($Tag->id);
     $this->assertIdentical($Tag->get('score'), 0);
 }
开发者ID:joeymetal,项目名称:v1,代码行数:10,代码来源:_AkActiveRecord_type_casting.php

示例14: tag_links

function tag_links($tags, $options = array())
{
    if (!$tags) {
        return null;
    }
    $prefix = !empty($options['prefix']) ? $options['prefix'] : '';
    if (is_string($tags)) {
        $tags = explode(' ', $tags);
        $tags = Tag::find(array('conditions' => array('name in (??)', $tags), 'select' => 'name, tag_type, post_count'));
    } elseif (is_array($tags)) {
        if (is_indexed_arr($tags) && count(current($tags)) == 2) {
            # We're getting a tag's cached_related tags. We need to find the tag type.
            $i = 0;
            $t = array();
            foreach ($tags as $tag) {
                $t[] = array('name' => current($tag), 'type' => Tag::type_name_helper(current($tag)), 'post_count' => end($tag));
            }
        } else {
            # We're getting a post's cached_tags. We need to find the count for each tag.
            $names = array_keys($tags);
            # We may have a misstyped metatag. Better return.
            if (!isset($names[0]) || !is_string($names[0])) {
                return;
            }
            $count = Tag::find_post_count_and_name('all', array('conditions' => array('name in (??)', $names), 'order' => 'name', 'return_array' => true));
            // vde($count);
            $i = 0;
            # There's a possibility a tag was deleted and cached_tags wasn't updated.
            # This will cause errors, so we'll just skip tags that weren't found.
            $t = array();
            foreach ($count as $tag) {
                $t[] = array('name' => $tag['name'], 'type' => $tags[$tag['name']], 'post_count' => $tag['post_count']);
            }
        }
        $tags = $t;
        unset($t);
    } elseif (is_a($tags, 'Tag')) {
        //
    }
    $tag_query = !empty(Request::$params->tags) ? Request::$params->tags : null;
    $html = '';
    foreach ($tags as $tag) {
        list($name, $type, $count) = array_values($tag);
        if (ctype_digit($type)) {
            $type = Tag::type_name($type);
        }
        $html .= '<li class="tag-type-' . $type . '"><a href="/tag?name=' . $name . '">?</a>';
        if (User::is('>=30')) {
            $html .= ' <a href="/post?tags=' . $name . '+' . $tag_query . '">+</a> <a href="/post?tags=-' . $name . $tag_query . '">&ndash;</a>';
        }
        $hover = !empty($options['with_hover_highlight']) ? " onmouseover='Post.highlight_posts_with_tag(\"{$name}\")' onmouseout='Post.highlight_posts_with_tag(null)'" : '';
        $html .= ' <a href="/post?tags=' . $name . '"' . $hover . '>' . str_replace('_', ' ', $name) . '</a> <span class="post-count">' . $count . '</span></li>';
    }
    return $html;
}
开发者ID:laiello,项目名称:my-imouto-booru,代码行数:55,代码来源:tag_helper.php

示例15: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $this->tag = Tag::find($id);
     $this->tag->fill(Input::all());
     if (!$this->tag->valid()) {
         return Redirect::back()->withInput()->with('errors', $this->tag->errors);
     } else {
         $this->tag->update();
         return Redirect::route('projects.index');
     }
 }
开发者ID:jcstrandburg,项目名称:portfoliowriter,代码行数:17,代码来源:TagController.php


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