How to concatenate first_name and last_name in pluck method using the relationship
i want to fetch the concatenated name of first_name and last_name as full_name in pluck method using relationship.
public function get_contacts(Request $request){
$account_id = $request->account_id;
$contacts = Account::find($account_id)->contacts()->get()->pluck('last_name', 'id');
return json_encode($contacts);
}
Models Account and Contact have intermediate table for many to many relationship.I don't now how to fetch full name in pluck method.Kindly share your knowledge. Thanks in advance.