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


PHP User::whereIn方法代码示例

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


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

示例1: scopeSearch

 /**
  * Search topics and posts.
  *
  * @param   QueryBuilder  $query
  * @param   string        $search
  * @param   bool          $includePosts
  * @return  QueryBuilder
  */
 public function scopeSearch($query, $search, $includePosts = True)
 {
     $search = trim($search);
     if (strlen($search)) {
         $parsed = Search::parseQuery($search, ['topic', 'post'], ['topic' => 'topic', 'post' => 'post', 'author' => 'author', 'by' => 'author']);
         // Search authors?
         $authors = !empty($parsed['author']) ? User::whereIn(DB::raw('LOWER(username)'), $parsed['author'])->lists('id') : [];
         $query->where(function ($query) use($parsed, $authors, $includePosts) {
             if (!empty($parsed['topic'])) {
                 $query->searchWhere(implode(' ', $parsed['topic']), 'name');
                 if ($authors && empty($parsed['post'])) {
                     $query->whereIn('author_id', $authors);
                 }
             }
             if ($includePosts && !empty($parsed['post'])) {
                 $query->orWhereHas('posts', function ($query) use($parsed, $authors) {
                     $query->searchWhere(implode(' ', $parsed['post']), 'post');
                     if ($authors) {
                         $query->whereIn('author_id', $authors);
                     }
                 });
             }
         });
     }
     return $query;
 }
开发者ID:anqqa,项目名称:oc-forum-plugin,代码行数:34,代码来源:Topic.php

示例2: scopeSearch

 /**
  * Search topics and posts.
  *
  * @param   QueryBuilder  $query
  * @param   string        $search
  * @return  QueryBuilder
  */
 public function scopeSearch($query, $search)
 {
     $parsed = Search::parseQuery($search, ['post'], ['post' => 'post', 'author' => 'author', 'by' => 'author']);
     // Search authors
     $authors = !empty($parsed['author']) ? User::whereIn(DB::raw('LOWER(username)'), $parsed['author'])->lists('id') : [];
     if ($authors) {
         $query->whereIn('author_id', $authors);
     }
     // Search posts
     if (!empty($parsed['post'])) {
         $query->searchWhere(implode(' ', $parsed['post']), 'post');
     }
     return $query;
 }
开发者ID:anqqa,项目名称:oc-forum-plugin,代码行数:21,代码来源:Post.php


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