本文整理汇总了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);
}
}
}