I know there is the answer to use asArray().
But what if I need model from relation and array at the same time?
In this example demoJson is without relations:
$demo = Demo::find()->with('bundles')->one();
// view
<?= var demoJson = json_encode($demo) ?> <!-- Using as array ERROR -->
<?= $demo->bundles[0]->someFunc() ?> <!-- Using model OK -->
In this example there is no someFunc() because a simple array used:
$demo = Demo::find()->with('bundles')->asArray()->one();
// view
<?= var demoJson = json_encode($demo) ?> <!-- Using as array OK -->
<?= $demo['bundles'][0]->someFunc() ?> <!-- Using model ERROR -->
So, how to get array from model with all its relations but without using asArray.