当前位置: 首页>>代码示例>>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;未经允许,请勿转载。