Добрый день,
мне нужно получить такой массив
[
0 => [
1 => app\models\UserModel#1
(
[yii\db\BaseActiveRecord:_attributes] => [
'id' => '2199'
'created' => '2015-12-14 13:12:51'
'modified' => '2015-12-14 13:12:51'
'days' => '1'
'xxx_id' => [
0 => 19
1 => 20
]
'is_active' => 1
]
[yii\db\BaseActiveRecord:_oldAttributes] => [
'id' => '2199'
'created' => '2015-12-14 13:12:51'
'modified' => '2015-12-14 13:12:51'
'days' => '1'
'xxx_id' => '20'
'is_active' => 1
]
[yii\db\BaseActiveRecord:_related] => []
[yii\base\Model:_errors] => null
[yii\base\Model:_validators] => null
[yii\base\Model:_scenario] => 'default'
[yii\base\Component:_events] => []
[yii\base\Component:_behaviors] => []
)
2 => app\models\UserModel#2
(
[yii\db\BaseActiveRecord:_attributes] => [
'id' => '2183'
'created' => '2015-12-14 13:12:51'
'modified' => '2015-12-14 13:12:51'
'days' => '2'
'xxx_id' => '1'
'is_active' => 1
]
[yii\db\BaseActiveRecord:_oldAttributes] => [
'id' => '2183'
'created' => '2015-12-14 13:12:51'
'modified' => '2015-12-14 13:12:51'
'days' => '2'
'xxx_id' => '1'
'is_active' => 1
]
[yii\db\BaseActiveRecord:_related] => []
[yii\base\Model:_errors] => null
[yii\base\Model:_validators] => null
[yii\base\Model:_scenario] => 'default'
[yii\base\Component:_events] => []
[yii\base\Component:_behaviors] => []
)
3 => app\models\UserModel#3
(....)
Как это сделать в foreach
$models = UserModel::findAll(['user_id' => \Yii::$app->user->identity->getId()]);
foreach ($models as $key => $value) {
$model[$value->days] = $value;
// $model[$value->days]->xxx_id[] = $value->xxx_id; - так не пашет
}
// $model[1]->availability_id = ['19', '20']; -- мне надо вот так добавить только в фориче по каждому
// $model[1]->availability_id = ['19', '20']; -- мне надо вот так добавить только в фориче по каждому