Answer the question
In order to leave comments, you need to log in
How to properly concatenate an ArrayHelpers::map array?
there is a model User the user has the properties first_name, last_name, mible_name I need to get the id and full name of the user I do this
$user=ArrayHelper::map(User::find()->asArray()->all(),'id','last_name'." ".'first_name'.' '.'midle_name');
Answer the question
In order to leave comments, you need to log in
1. Make a method in the model
public function getName()
{
return $this->last_name . ' ' .$this->first_name . ' ' .$this->middle_name;
}
$users = ArrayHelper::map(User::find()->all(), 'id', 'name');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question