Answer the question
In order to leave comments, you need to log in
How to properly separate AR and business logic for entities in Yii2?
There is a project on Yii2 and it was decided to separate AR models and logic for them.
I thought to allocate the data storage logic to the repository, but, as I understand it, AR itself implements this pattern.
Now I have the following structure in mind:
app\models\ActiveRecord\Base\BaseFoo - here I store the main class of the model, which is inherited from yii\db\ActiveRecord , at the moment the content is the following: tableName(), validation rules, scripts,
app attribute labels \models\ActiveRecord\Foo - inherit from BaseFoo , behaviors() description if necessary, and logic description here.
Is this structure acceptable? You can, of course, move the Foo model to app\models\Logicor something like that, but I think it's better to store it in app\models\ActiveRecord .
I would be grateful for any alternatives, your own approach in describing the structure of the application is interesting.
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