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


PHP Tag::where方法代码示例

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


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

示例1: validate_tag

 protected function validate_tag()
 {
     if (!Tag::where(['name' => $this->name])->first()) {
         $this->errors()->add('tag', "couldn't be created");
         return false;
     }
 }
开发者ID:JCQS04,项目名称:myimouto,代码行数:7,代码来源:TagAlias.php

示例2: show

 public function show($name)
 {
     $tag = Tag::where('name', '=', $name)->firstOrFail();
     $articles = $tag->articles()->where('cid', '>', '0')->with('category')->orderBy('id', 'desc')->paginate(10);
     $values = array('title' => '标签:' . $tag->name . '_', 'tag' => &$tag, 'articles' => &$articles);
     return View::make('tag.show', $values);
 }
开发者ID:xiaohulidudu,项目名称:laravel-blog,代码行数:7,代码来源:TagController.php

示例3: getTagPosts

 public function getTagPosts($name)
 {
     try {
         $tag = Tag::where('name', $name)->first();
         if (!$tag) {
             throw new Exception("Tag not found");
         }
         $posts = $tag->posts()->paginate(8);
         $i = 0;
         foreach ($posts as $post) {
             if (!PrivacyHelper::checkPermission(Auth::user(), $post)) {
                 unset($posts[$i]);
                 $i++;
                 continue;
             }
             $i++;
             $post->makrdown = str_limit($post->makrdown, $limit = 500, $end = '...');
             $Parsedown = new Parsedown();
             $post->HTML = $Parsedown->text($post->makrdown);
         }
         if (Request::ajax()) {
             return View::make('posts._list')->with('data', $posts);
         } else {
             if (count($posts) == 0) {
                 return Redirect::intended(URL::action('ProfileController@getProfile', array($id)));
             }
             $this->layout->content = View::make('posts.list')->with('data', $posts);
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:sh1nu11bi,项目名称:CloMa,代码行数:32,代码来源:BlogController.php

示例4: getTagByName

 public static function getTagByName($name)
 {
     if (empty($name)) {
         return null;
     }
     return Tag::where('name', '=', $name);
 }
开发者ID:rituzy,项目名称:iblog,代码行数:7,代码来源:Tag.php

示例5: submit

 function submit()
 {
     $data['title'] = 'Submit a Project';
     $project = new Project();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         // Get the scalars.
         $project->from_array($_POST);
         // Convert properly to boolean
         if ($project->show_contact == 'yes') {
             $project->show_contact = TRUE;
         } else {
             $project->show_contact = FALSE;
         }
         // Handle the relations (tags)
         if ($project->save($this->_current_user())) {
             // validations run
             $this->_save_tags($project);
             $this->_submit_on_success();
         } else {
             // invalid
             $data['error'] = $project->error->string;
         }
     }
     // Otherwise, render a form.
     $tags = new Tag();
     foreach (array('field', 'type', 'location') as $category) {
         $tags->where('category', $category)->get();
         $data[$category . '_tags'] = array();
         foreach ($tags as $tag) {
             array_push($data[$category . '_tags'], $tag->name);
         }
     }
     $data['form'] = $project->render_form(array('title', 'start_date', 'end_date', 'field', 'type', 'location', 'text', 'show_contact'));
     $this->load->view('form_project', $data);
 }
开发者ID:kuitang,项目名称:sdi,代码行数:35,代码来源:home.php

示例6: index

 public function index()
 {
     $tags = User::find(Auth::user()->id)->tags()->get();
     $tags = Tag::where('user_id', '=', Auth::user()->id)->orWhereHas('notes', function ($query) {
         $query->whereHas('users', function ($query) {
             $query->where('note_user.user_id', '=', Auth::user()->id);
         });
     })->where('visibility', '=', 1)->get();
     return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $tags);
 }
开发者ID:netesheng,项目名称:paperwork,代码行数:10,代码来源:ApiTagsController.php

示例7: createOrGetTags

 public static function createOrGetTags($tagsArray, $noteId, $noteUmask)
 {
     $tagsPublicPrefixCharacter = Config::get('paperwork.tagsPublicPrefixCharacter')[0];
     $createdOrFoundIds = array();
     if (is_null($tagsArray)) {
         return null;
     }
     $userId = Auth::user()->id;
     foreach ($tagsArray as $tagItem) {
         $tagTitle = '';
         $tagVisibility = 0;
         if ($tagItem[0] === $tagsPublicPrefixCharacter) {
             $tagTitle = strtolower(substr($tagItem, 1));
             $tagVisibility = 1;
             $tag = Tag::where('tags.title', '=', $tagTitle)->where('tags.visibility', '=', $tagVisibility)->first();
         } else {
             $tagTitle = strtolower($tagItem);
             $tagVisibility = 0;
             $tag = Tag::where('tags.title', '=', $tagTitle)->where('tags.visibility', '=', $tagVisibility)->where('tags.user_id', '=', $userId)->first();
         }
         // ->where('tags.title', '=', $tagTitle)
         // ->where('tags.visibility', '=', $tagVisibility)
         // ->select('tags.id')
         // ->first();
         if (is_null($tag) && ($tagVisibility == 0 || $tagVisibility == 1 && $noteUmask > PaperworkHelpers::UMASK_READONLY)) {
             $newTag = new Tag();
             $newTag->title = $tagTitle;
             $newTag->visibility = $tagVisibility;
             $newTag->user_id = $userId;
             $newTag->save();
             //$newTag->users()->attach(Auth::user()->id);
             $createdOrFoundIds[] = $newTag->id;
         } else {
             if ($tagVisibility == 0 || $tagVisibility == 1 && $noteUmask > PaperworkHelpers::UMASK_READONLY) {
                 /*if(is_null($tag->users()->where('users.id', '=', Auth::user()->id)->first())) {
                 			$tag->users()->attach(Auth::user()->id);
                 		}*/
                 $createdOrFoundIds[] = $tag->id;
             }
         }
     }
     //we need to add the other user's private tags to the list.
     $addtags = Note::find($noteId)->tags()->where('tags.visibility', '=', 0)->where('tags.user_id', '!=', $userId)->get();
     foreach ($addtags as $addtag) {
         $createdOrFoundIds[] = $addtag->id;
     }
     //if the user is not writer, he cannot change public tags.
     if ($noteUmask < PaperworkHelpers::UMASK_READWRITE) {
         $addpubtags = Note::find($noteId)->tags()->where('tags.visibility', '=', 1)->get();
         foreach ($addpubtags as $addtag) {
             $createdOrFoundIds[] = $addtag->id;
         }
     }
     return $createdOrFoundIds;
 }
开发者ID:jinchen891021,项目名称:paperwork,代码行数:55,代码来源:ApiTagsController.php

示例8: addTagOrCreateNew

 public function addTagOrCreateNew($tag, $user_id = 0)
 {
     $tagFound = Tag::where('id', '=', $tag)->first();
     if (!isset($tagFound)) {
         $tagFound = new Tag();
         $tagFound->name = $tag;
         $tagFound->user_id = $user_id;
         $tagFound->save();
     }
     $tagFound->crafts()->save($this);
 }
开发者ID:rituzy,项目名称:iblog,代码行数:11,代码来源:Craft.php

示例9: filterResources

 public function filterResources()
 {
     $name = Input::get('name');
     $tag = Tag::where('name', 'LIKE', $name . '%')->get();
     if (Request::ajax()) {
         foreach ($tag as $tag_name) {
             $results[] = $tag_name->name;
             print_r($results);
         }
         return json_encode(array('tags' => $results));
     }
     $this->layout->content = View::make('tags.resource_tag')->with('tag', $tag);
 }
开发者ID:shankargiri,项目名称:Quantum-Vic-La-Trobe-L4,代码行数:13,代码来源:TagsController.php

示例10: validateTag

 public function validateTag($attribute, $value, $parameters, $validator)
 {
     $requiredReputation = $parameters[0];
     // required reputation points
     $userReputation = auth()->guest() ? 0 : auth()->user()->reputation;
     if ($userReputation >= $requiredReputation) {
         return true;
     }
     $tag = Tag::where('name', $value)->pluck('id');
     if ($tag) {
         return true;
     }
     return false;
 }
开发者ID:furious-programming,项目名称:coyote,代码行数:14,代码来源:TagCreationValidator.php

示例11: explode

 function _do_tag_filtering($options)
 {
     if ($options['tags_not']) {
         $not = true;
         $options['tags'] = $options['tags_not'];
     } else {
         $not = false;
     }
     $tags = explode(',', urldecode($options['tags']));
     if ($options['match_all_tags'] || $not) {
         $content_ids = false;
         $model = $this->model === 'album' ? 'albums' : $this->model;
         foreach ($tags as $tag) {
             $t = new Tag();
             $t->where('name', $tag)->get();
             if ($t->exists()) {
                 $tag_content_ids = array();
                 foreach ($t->{$model}->select('id')->get_iterated() as $content) {
                     $tag_content_ids[] = $content->id;
                 }
                 if ($content_ids === false) {
                     $content_ids = $tag_content_ids;
                 } else {
                     if ($options['match_all_tags']) {
                         $content_ids = array_intersect($content_ids, $tag_content_ids);
                     } else {
                         $content_ids = array_merge($content_ids, $tag_content_ids);
                     }
                 }
             }
         }
         if ($not) {
             $this->where_not_in('id', $content_ids);
         } else {
             $this->where_in('id', $content_ids);
         }
     } else {
         $this->distinct();
         $this->group_start();
         foreach ($tags as $tag) {
             $t = new Tag();
             $t->where('name', $tag)->get();
             if ($t->exists()) {
                 $this->or_where_related('tag', 'id', $t->id);
             }
         }
         $this->group_end();
     }
 }
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:49,代码来源:koken.php

示例12: decrementCount

 /**
  * Private! Please do not call this function directly, let the Tag library use it.
  * Decrement count of tag by one. This function will create tag record if it does not exist.
  *
  * @param string $tagString
  */
 public static function decrementCount($tagName, $count, $tag = null)
 {
     if ($count <= 0) {
         return;
     }
     if (!$tag) {
         $tag = Tag::where('tag', '=', $tagName)->first();
     }
     $tag->count = $tag->count - $count;
     if ($tag->count < 0) {
         $tag->count = 0;
         \Log::warning("The \\App\\Modules\\Tag count for `{$tag->name}` was a negative number. This probably means your data got corrupted. Please assess your code and report an issue if you find one.");
     }
     $tag->save();
 }
开发者ID:sharenjoy,项目名称:axes,代码行数:21,代码来源:TagUtil.php

示例13: getTag

 public function getTag($tag)
 {
     $filtered_tags = array();
     $tags = Tag::where('name', '=', $tag)->orderBy('confidence', 'desc')->get();
     foreach ($tags as $tag_object) {
         if ($tag_object->image) {
             foreach ($tag_object->image->tags()->orderBy('confidence', 'desc')->take(5)->get() as $image_tag) {
                 if ($image_tag->name == $tag) {
                     array_push($filtered_tags, $tag_object);
                 }
             }
         }
     }
     return View::make('photos.tag', array('tag' => $tag, 'tags' => $filtered_tags));
 }
开发者ID:siyana-plachkova,项目名称:tagcloud,代码行数:15,代码来源:PhotosController.php

示例14: tag

 public function tag($the_tags)
 {
     $ids = array();
     foreach ($the_tags as &$tag_str) {
         $tag_str = Str::slug(trim($tag_str));
         $tag = Tag::where('name', '=', $tag_str)->first();
         if ($tag) {
             $tag->count = $tag->count + 1;
             $tag->save();
             $ids[] = $tag->id;
         } else {
             $tag = Tag::create(array('name' => $tag_str, 'count' => 1));
             $ids[] = $tag->id;
         }
     }
     $this->tags()->sync($ids);
 }
开发者ID:jvillasante,项目名称:cubanartjb,代码行数:17,代码来源:painting.php

示例15: json_list

 /**
  * Json list
  */
 public function json_list()
 {
     if (strlen(Input::get('term')) >= 2) {
         $q = Tag::where('name', 'LIKE', '%' . Input::get('term') . '%');
         if (Input::get('olds')) {
             $tags = explode(',', Input::get('olds'));
             $q->whereNotIn('id', $tags);
         }
         $list = $q->lists('name', 'id');
     } else {
         $list = array();
     }
     $ajaxArray = array();
     foreach ($list as $key => $value) {
         $ajaxArray[] = array("name" => $value);
     }
     return Response::json($ajaxArray);
 }
开发者ID:urashima82,项目名称:intranet,代码行数:21,代码来源:TagController.php


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