public function getPhotos(): ActiveQuery
{
return $this->hasMany(Photos::class, ['product_id' => 'id'])->orderBy('sort');
}
public function getValues(): ActiveQuery
{
return $this->hasMany(Values::class, ['product_id' => 'id']);
}
public function behaviors(): array
{
return [
[
'class' => SaveRelationsBehavior::class,
'relations' => ['photos', 'values'] // отслеживаемые связи продукта, изображения и характеристики
]
];
}
$bookId = Yii::$app->request->post('editableKey');
$model = Products::findOne($bookId);
$out = Json::encode(['output'=>'', 'message'=>'']);
$posted = current($_POST['Products']);
$post = ['Products' => $posted];
$posted = current($_POST['Products']);