I'm building an API for a comments APP and I want to first display the comments that the logged user owns I've tryed to make an order by that checks if the user id of the comment matches the user id of the logged user that's what i have
$comments = Comment::where('project_id', $request->id)
->join('users', 'users.id', '=', 'comments.user_id')
->select('users.name', 'comments.*')
->orderBy('users.id', '=', [Auth::user()->id])
->orderBy('comments.created_at', 'DESC')
->get();