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


PHP Reference::where方法代碼示例

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


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

示例1: allUserData

 /**
  * @param $id
  */
 public function allUserData($id, $mode = 'show')
 {
     if (!($user = User::find($id))) {
         abort(404);
     }
     $name = $user->full_name;
     if (!($fullProfile = Profile::where('user_id', '=', $id)->first())) {
         $fullProfile = new Profile();
     }
     $cityLiving = $this->placeLiving($fullProfile->place_living_id);
     $cityFrom = $this->placeFrom($fullProfile->place_from_id);
     $languages_high = Language::where('profile_id', '=', $fullProfile->id)->where('level', '=', 'advanced')->get();
     $languages_med = Language::where('profile_id', '=', $fullProfile->id)->where('level', '=', 'intermediate')->get();
     $languages_low = Language::where('profile_id', '=', $fullProfile->id)->where('level', '=', 'basic')->get();
     //Avatar is optional
     if ($user->avatar) {
         $avatar = $user->avatar;
     }
     if ($mode == 'show' || $mode == 'references') {
         $references = Reference::where('profile_user_id', '=', $id)->with(['user'])->orderBy('updated_at', 'DES')->get();
         $age = $user->age;
         $owner = \Auth::id() == $id;
         $gender = $user->gender;
         $places = $user->placesWanted;
         $placesVisited = $user->placesVisited;
         $avg = Reference::where('profile_user_id', '=', $id)->avg('grade');
         $ref = false;
         $fav = boolval(Favorites::where('owner_id', \Auth::id())->where('user_id', $id)->first());
         if ($mode == 'references') {
             $ref = true;
         }
         return compact('fullProfile', 'references', 'name', 'avatar', 'ref', 'avg', 'cityFrom', 'cityLiving', 'age', 'gender', 'id', 'owner', 'fav', 'languages_high', 'languages_med', 'languages_low', 'places', 'placesVisited');
     } else {
         if ($mode == 'edit') {
             return compact('fullProfile', 'cityFrom', 'cityLiving', 'name', 'avatar', 'id', 'languages_high', 'languages_med', 'languages_low');
         } else {
             return abort(404);
         }
     }
 }
開發者ID:charlieboo,項目名稱:creatrip,代碼行數:43,代碼來源:MethodsProfile.php


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