returning value from another method laravel code example

Example 1: javascript return multiple values from a function

//function that returns multiple values
function getTopTwoColors() {
    return ["blue", "pink"];
}
var topTwoColors=getTopTwoColors();
var firstValue=topTwoColors[0]; //get first return value
var secondValue=topTwoColors[1]; //get second return value

Example 2: rest api django return value if exists in another table

class PostList(generics.ListAPIView):
    ...
    def get_queryset(self):
        Post.objects.all().extra(select={
        'current_user_replies_count': 'SELECT COUNT(*) FROM <reply table> WHERE' +
        'post_id=posts_post.id AND owner_id = %s'
                                  },select_params=(request.user.id,))