Answer the question
In order to leave comments, you need to log in
How to create a model with dynamic attributes (EAV) in Yii2?
Hello!
I ran into such a problem, I can’t understand how to correctly implement models in Yii 2 for such a database schema:
In fact, this is a familiar EAV to everyone - there is an object, the object has properties that are set dynamically.
To implement this task through pure SQL or QueryBuilder will not be any particular problem. But I want to be able to conveniently get and change these dynamic attributes. For example:
...
echo $model->description; // Получаем свойство "Описание"
$model->name = 'Object #1'; // Задаем новое Имя для объекта
$model->save();
...
Answer the question
In order to leave comments, you need to log in
https://github.com/Mirocow/yii2-eav
This is an improved and working implementation of the russianlagman/yii2-eav module
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question