Answer the question
In order to leave comments, you need to log in
What is the correct way to concatenate an array and an object?
The code
//Юзер
$user = Auth::user();
//Телефон и вебсайт
$contact['phone'] = $user->phone;
$contact['website'] = $user->website;
//Локейшен
if (!$location=$user->location) {
$location = new UserLocation;
}
//Объединяем данные
$contact = array_merge($contact, array($location));
return response()->json($contact);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question