當前位置: 首頁>>代碼示例>>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方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadUserInfo

 public function loadUserInfo()
 {
     $peopleWithAvatars = [];
     $avatars = Avatar::where('attachment_type', 'RainLab\\User\\Models\\User')->where('field', 'avatar')->get();
     foreach ($avatars as $avatr) {
         $this->avatars[$avatr->attachment_id] = ['t600' => $avatr->getThumb(600, 600), 't200' => $avatr->getThumb(200, 200), 'filename' => $avatr->filename];
         $peopleWithAvatars[] = $avatr->attachment_id;
     }
     // Set Pagination parameters
     $this->perPage = $this->property('PicsPerPage', 12);
     $this->currentPage = input('page', 1);
     $sort3 = null;
     /*
      * Sorting
      */
     switch ($this->sort) {
         case 'last':
             $sort1 = 'surname';
             $sort2 = 'name';
             break;
         case 'given':
             $sort1 = 'name';
             $sort2 = 'surname';
             break;
         default:
             $sort1 = 'primary_usergroup';
             $sort2 = 'surname';
             $sort3 = 'name';
     }
     $people = user::wherein('id', $peopleWithAvatars)->orderBy($sort1)->orderBy($sort2);
     if ($sort3) {
         $people->orderBy($sort3);
     }
     $this->people = $people->paginate($this->perPage, $this->currentPage);
     /*
      * Pagination
      */
     if ($this->people) {
         $queryArr = [];
         $queryArr['sort'] = $this->sort;
         $queryArr['page'] = '';
         $paginationUrl = Request::url() . '?' . http_build_query($queryArr);
         if ($this->currentPage > ($this->lastPage = $this->people->lastPage()) && $this->currentPage > 1) {
             return Redirect::to($paginationUrl . $this->lastPage);
         }
         $this->firstItem = $this->people->firstItem();
         $this->lastItem = $this->people->lastItem();
         $this->total = $this->people->total();
         $this->paginationUrl = $paginationUrl;
     }
     return $this->people;
 }
開發者ID:aydancoskun,項目名稱:octobercms,代碼行數:52,代碼來源:Gallery.php


注:本文中的RainLab\User\Models\User::wherein方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。