N
N
Nick Tit2015-11-12 16:32:59
Yii
Nick Tit, 2015-11-12 16:32:59

Yii2 where to write the business logic of an online store?

Controller
Model
Separate
Module

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
totudub, 2015-11-12
@totudub

https://github.com/yiisoft/yii2/blob/master/docs/g...

V
Viktor, 2015-11-12
@master2016

Depending on which architecture you prefer. If you do not want to overload controllers with functionality (which is basically correct), load models and helpers with logic.

N
Nick Tit, 2015-11-12
@tit777

example
There is an online store.
For example, I want to implement a cart
action: viewCart
here is the business logic of the cart:
1) getting all delivery methods
2) recalculating goods in the cart
3) adding goods to the cart
4) order amount
5) checking goods in the database
6) recalculating goods in the cart
displaying on the screen cart details
Define a set of base model classes that are common to different applications or modules. These model classes should contain a minimal set of rules and logic that are common across all applications or modules used.
In each application or module that uses the model, define a specific model class (or model classes) that derives from the corresponding base model class. A particular model class must contain rules and logic that are specific to that application or module.
The idea is pleasant to me, and it is possible implementation for clearness?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question