當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Member::withTrashed方法代碼示例

本文整理匯總了PHP中app\Member::withTrashed方法的典型用法代碼示例。如果您正苦於以下問題:PHP Member::withTrashed方法的具體用法?PHP Member::withTrashed怎麽用?PHP Member::withTrashed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Member的用法示例。


在下文中一共展示了Member::withTrashed方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: numMembers

 private function numMembers()
 {
     $numActive = Member::all()->where('is_active', 1)->count();
     $numInactive = Member::all()->where('is_active', 0)->count();
     $numDischarged = Member::onlyTrashed()->count();
     $numTotal = Member::withTrashed()->count();
     return ['numActive' => $numActive, 'numInactive' => $numInactive, 'numDischarged' => $numDischarged, 'numTotal' => $numTotal];
 }
開發者ID:alansfyeung,項目名稱:FLARES,代碼行數:8,代碼來源:DashboardController.php

示例2: search

 /**
  * Search the resource by providing a querystring
  *
  * @return Response
  */
 public function search(Request $request)
 {
     // ?discharged -- [ none | include | only ]
     $withDischarged = $request->query('discharged', 'none');
     if ($withDischarged == 'include') {
         $query = Member::withTrashed();
     } elseif ($withDischarged == 'only') {
         $query = Member::onlyTrashed();
     } else {
         $query = Member::select();
     }
     // join on 3p table
     $query->leftJoin('posting_promo', function ($join) {
         $join->on('members.regt_num', '=', 'posting_promo.regt_num');
     });
     $query->select('members.*', 'posting_promo.new_rank as rank');
     if ($request->has('keywords')) {
         $keywords = explode(' ', $request->query('keywords'));
         foreach ($keywords as $keyword) {
             // If keyword resembles a regt number_format
             if ($this->keywordLikeRegtNum($keyword)) {
                 $query->where('members.regt_num', 'like', "{$keyword}%");
                 continue;
             }
             // If keyword matches a known rank abbrev
             if ($this->keywordLikeRank($keyword)) {
                 $rank = $this->keywordExtractRank($keyword);
                 $query->where('rank', $rank);
                 continue;
             }
             // Otherwise add this as a name search
             $query->where(function ($query) use($keyword) {
                 $query->where('last_name', 'like', "%{$keyword}%")->orWhere('first_name', 'like', "%{$keyword}%");
             });
         }
     } else {
         foreach ($request->only('rank', 'last_name', 'first_name', 'regt_num') as $name => $input) {
             $input = trim($input);
             if (!empty($input)) {
                 $query->where($name, 'like', "{$input}%");
                 $query->orderBy($name, 'asc');
             }
         }
         foreach ($request->only('sex') as $name => $input) {
             // ('sex', 'is_active')
             $input = trim($input);
             if (!empty($input)) {
                 $query->where($name, $input);
             }
         }
     }
     // return var_dump($input);
     return response()->json(['members' => $query->get()]);
 }
開發者ID:alansfyeung,項目名稱:FLARES,代碼行數:59,代碼來源:MemberController.php


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