Answer the question
In order to leave comments, you need to log in
How to separate model logic in Yii2 advanced?
Let's say there is a Requests model in common. It has the following methods:
static function getActiveStates()
{
if (Yii::$app->params['isBackend']) {
$activeStates = [
Requests::STATE_READY,
Requests::STATE_CONFIRM,
Requests::STATE_CONFIRM_PAID,
Requests::STATE_PAID
];
} else {
$activeStates = [
Requests::STATE_NEW,
Requests::STATE_READY,
Requests::STATE_ATROUT,
Requests::STATE_CONFIRM,
Requests::STATE_CONFIRM_PAID,
Requests::STATE_PAID
];
}
return $activeStates;
}
public function isActiveState()
{
return in_array($this->state_id,Requests::getActiveStates());
}
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