Answer the question
In order to leave comments, you need to log in
How can I change the Json output (structure)?
I want to change the output of all Returns
{
"success": true,
"payload": {
/* Application-specific data would go here. */
Тут возвращать модель $model
}
}
{
"success": false,
"payload": {
/* Application-specific data would go here. */
},
"error": {
Тут $model->errors
}
}
Answer the question
In order to leave comments, you need to log in
They helped in the chat ( https://gitter.im/yiisoft/yii2/rus ) and posted it to the forum, who is interested
yiiframework.ru/forum/viewtopic.php?f=30&t=29318&p...
Inherit controllers from some BaseController. In it, create a method that will receive a model, something else - and output the result in the desired format.
Alternatively, create a trait.
Go to yii2.
Read about www.yiiframework.com/doc-2.0/guide-rest-response-f...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question