D
D
Dmitry Kiryushin2015-11-20 14:23:31
Yii
Dmitry Kiryushin, 2015-11-20 14:23:31

How to get static data of a function when selecting a model in Yii2?

get company models via $data = Company::find()->all();
the sum of active projects at the moment is also considered in the model
after sending via Json::decode();
How can I get the sum of active projects of the company in Json format?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2015-11-20
@dmitriykiryushin

1. why not right away? asArray()->all()?
2. run the resulting array through a loop, something else and calculate the required amount already there and add a field ..
echo Json::encode(['data'=>$data, 'sum'=>$YouSumm]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question