sktklaus
5 months ago

response data Relations

Posted 5 months ago by sktklaus

I have my users and TeamLeads Users:: TeamLeads::

If I get the users, the response starts like this

{
    "success":true,"message":"Success",
    "data":{
        "current_page":2,"data":
        [
            {"country":"IN","title":null,"type":"specialist"}
        ]
    }
}

How can I add an attribute to every user in the response, if the id exists in another table?

$leaderIds = TeamLeadUserMap::get()->pluck('userId');

and return

{
    "success":true,"message":"Success",
    "data":{
        "current_page":2,"data":
        [
            {TeamLead:true, "country":"IN","title":null,"type":"specialist"}
        ]
    }
}

Please sign in or create an account to participate in this conversation.