Lately, I'm using domain model pattern, and my controllers methods often looks like (yii2 example, verify user in loyalty system with Ajax response).
if (LoyaltyDomModel::loyaltyVerification($post_data)) {
if (LoyaltyDomModel::setVerify(Yii::$app->user->identity, $post_data)) {
return ['body'=>'successfull','status' => true];
}
else {
return ['body'=>'unable update user','status' => 'error'];
}
}
else {
return ['body'=>'errorcardno','status' => 'error'];
}
If logic is more complex I have a lot of if statement with model methods which return bool values, for example (I'm trying to decouple models logic in atomic methods), and it looks like not healthy. Should I encapsulate logic of return errors in models? What is best practices?