本文整理汇总了PHP中Rating::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::orderBy方法的具体用法?PHP Rating::orderBy怎么用?PHP Rating::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::orderBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActivity
public static function getActivity()
{
$user_id = Session::get('user_id');
$error_code = ApiResponse::OK;
$act = array();
$ratings = Rating::where('user_id', $user_id)->get();
foreach ($ratings as $rating) {
$likes = Like::where('rating_id', $rating->id)->whereNotIn('user_id', [$user_id])->get();
if ($likes) {
$title = 'like';
foreach ($likes as $like) {
$act[] = Rating::getProfile($like->user_id, $title, $like->id, $rating->id, $like->updated_at);
}
}
$comments = Comment::where('rating_id', $rating->id)->whereNotIn('user_id', [$user_id])->get();
if ($comments) {
$title = 'comment';
foreach ($comments as $comment) {
$act[] = Rating::getProfile($comment->user_id, $title, $comment->id, $rating->id, $comment->updated_at);
}
}
$wishlists = Wishlist::where('wine_unique_id', $rating->wine_unique_id)->whereNotIn('user_id', [$user_id])->get();
if ($wishlists) {
$title = 'wishlist';
foreach ($wishlists as $wishlist) {
$act[] = Rating::getProfile($wishlist->user_id, $title, $wishlist->id, $rating->id, $wishlist->updated_at);
}
}
}
$user_follow = Follow::where('to_id', $user_id)->get();
if ($user_follow) {
$title = 'follow';
foreach ($user_follow as $user) {
$act[] = Rating::getProfile($user->from_id, $title, $user->id, null, $user->updated_at);
}
}
$data = Rating::orderBy($act, 'updated_at');
return array("code" => $error_code, "data" => $data);
}