Answer the question
In order to leave comments, you need to log in
How to use models for backend and frontend modules in Yii2 advanced?
Hello! All the same, I decided to ask those who know about the correct structure of Yii2 advanced based on modules. How to organize the following situation correctly, for example:
There is a Pages module in the frontend, so it needs an admin panel, also in the form of a module in the backend, where to store the models for these modules? common? Then somehow the structure of the very concept of a module breaks ... it turns out scattered. Yes, and here you can create CRUD only where this model lies in the front or backend, swears at the namespace. Is it just like that?
Here is such nonsense with CRUD - one wonders why it does not allow placing files in different directories ??? and what's the problem with the Base Controller Class?
The picture is not displayed) - https://habrastorage.org/files/317/45e/d58/31745ed...
Answer the question
In order to leave comments, you need to log in
What specific error occurs with namespaces and what do you do about it?
If you can refer to models from the common\models namespace, there is no restriction on referencing them somewhere in frontend\modules\page\models.
In CRUD, gii tries to generate children from the main models. From the common\models\Product model, it is quite possible to inherit some kind of backend\models\ProductSearch and use it in the admin panel for search.
it turns out that most models will be common for the front and backend, the meaning of modularity is lost for me...
I'm a beginner myself, and I may say something stupid, correct me if I'm wrong.
The meaning is not lost if you make the module of the same name in the backend, in the vrontend and in the comon, put the general models in /common/modules/page/model and put those that you don’t need both in the vronde and in the backend in the scope you need, and By the way, the fact that you write an error when generating CRUD, so there is nothing terrible here, just correct the namespaces.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question