I'm using common Yii2 ActiveController
REST implementaion:
class ResultController extends ActiveController
{
public $modelClass = 'app\models\Result';
public function actionResultList($id)
{
/* @var $modelClass \yii\db\BaseActiveRecord */
$modelClass = $this->modelClass;
return new ActiveDataProvider...
It works all good for me, except one feature - I've got some JSON stored in my Result->rawJson
model as string. When I'm outputting it through this controller it gets escaped with slashes, and angular on frontend treats it as a string. The question is how to tell serializer not to serialize several model fields and pass them 'as is'.
I found only this dirty hack to do it, i've added afterFind
in my model class:
public function afterFind()
{
$this->rawJson= json_decode($this->rawJson);
}
I'll appreciate any help on this, thanks in advance.