Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static function getPostsByIdWall($idWall, $orderBy){
- return DB::table('wall')->select('wall.id', 'wall.user_id', 'wall.description',
- 'wall.created_at', 'users.name as user_name',
- 'likes.post_id as liked_id', 'ignored.post_id as ignored_post_id', 'ignored.user_id as ignored_by')
- ->join('users', 'wall.user_id', '=', 'users.id')
- ->leftJoin('ignored', function ($join) {
- $join->on('wall.id', '=', 'ignored.post_id')
- ->where([['ignored.user_id', '=', Auth::id()], ['ignored.status', '=', 'post']]);
- })
- ->leftJoin('likes', function ($join) {
- $join->on('wall.id', '=', 'likes.post_id')
- ->where([['likes.user_id', '=', Auth::id()], ['likes.status', '=', 'post']]);
- })
- ->where('wall.user_id', '=', $idWall)
- ->orderBy(...$orderBy)
- ->get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement