当前位置: 首页>>代码示例>>PHP>>正文


PHP Rating::orderBy方法代码示例

本文整理汇总了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);
 }
开发者ID:anht37,项目名称:winelover_server,代码行数:39,代码来源:Rating.php


注:本文中的Rating::orderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。