Get all attributes of a model incl. foreign tables (convert model recursively to multidimensional array)


I’m search a way to loop through a returned model / all attributes incl. recursive values (activerecord) which is related to foreign tables by objects. I’ve tried to convert the model by means of toArray() function but I got only the foreign key but I need there a multidimensional array inlcuding sub arrays with content of he foreign tables.

Does anybody have an idea?

Best regards,

Nobody a solution? :sleepy:

Hi @strtob,

Have you tried it using “with”? Something like:

$models = SomeModel::find()->with('relation_model')->all()->asArray();