Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1.   private static function getPostsByIdWall($idWall, $orderBy){
  2.     return DB::table('wall')->select('wall.id', 'wall.user_id', 'wall.description',
  3.                                               'wall.created_at', 'users.name as user_name',
  4.                                               'likes.post_id as liked_id', 'ignored.post_id as ignored_post_id', 'ignored.user_id as ignored_by')
  5.                       ->join('users', 'wall.user_id', '=', 'users.id')
  6.                       ->leftJoin('ignored', function ($join) {
  7.                         $join->on('wall.id', '=', 'ignored.post_id')
  8.                               ->where([['ignored.user_id', '=', Auth::id()], ['ignored.status', '=', 'post']]);
  9.                       })
  10.                       ->leftJoin('likes', function ($join) {
  11.                         $join->on('wall.id', '=', 'likes.post_id')
  12.                               ->where([['likes.user_id', '=', Auth::id()], ['likes.status', '=', 'post']]);
  13.                       })
  14.                       ->where('wall.user_id', '=', $idWall)
  15.                       ->orderBy(...$orderBy)
  16.                       ->get();
  17.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement