Answer the question
In order to leave comments, you need to log in
Yii. How do you design your models?
Good afternoon.
How do you design your models for backend, frontend and other like api modules?
I will describe my difficulties using the example of the PRODUCT model.
On the one hand, there are a large number of common methods for Product classes in all modules, for example:
public function getPrice() {
return format($this->price);
}
public function defaultScope()
{
return [
'condition'=>'active=1,
];
}
Answer the question
In order to leave comments, you need to log in
Discover the DDD path. The domain model for the entire application is one and is not tied to framework modules and in general. True, in the context of Yii, it will not work to make pure models, php is still not ruby.
In the common section, it is convenient to define common methods for working with an entity. And the specification of the entity in relation to tasks and business logic should be separated by destinations: backend, frontend, api. It is more important to separate models and business logic than models in sections, IMHO.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question